how to define a fiven input is an array or not code example

Example 1: take array as input in c

int size=5;
int array[size]; // array of size=5;

for(i=0;i<size;i++){
   scanf("%d",&array[i]);
                }

Example 2: how to make a c# array

// Syntax: 
datatype_variable[dimension] = new datatype[size]{array};

// For example:
string MyArray[] = new string[1]{"Hello","World"};

// or just:
string MyArray[]={"Hello","world"};

// for multidimensions:
// 2D array:
         	  // 2 arrays, 3 values //
int MyArray=[,]=new int[1,2]{
  {1,2,3},
  {1,2,3}
}

// 3D array:
              // 2 arrays, 3 arrays, 4 values //
int MyArray=[,,]=new int[1,2,3]{
  {
    {1,2,3,4},
    {1,2,3,4},
    {1,2,3,4}
  },
  {
    {1,2,3,4},
    {1,2,3,4},
    {1,2,3,4}
  }
}

Tags:

Misc Example