c++ array function code example
Example 1: array syntax in c++
int foo [] = { 16, 2, 77, 40, 12071 };
Example 2: array as parameter c++
void myFunction(int param[]) {
.
.
.
}
Example 3: array in c++
int a[2][3]= {
{1, 2, 3},
{4, 5, 6}
};
cout << a[1][1];
int a[2][3][2]= {
{ {1, 2},
{2, 3},
{4, 5}
},
{ {6, 7},
{8, 9},
{10, 11}
}
};
cout << a[0][1][1];
Example 4: passing array to function c++ pointer
void generateArray(int *a, int si)
{
for (int j = 0; j < si; j++)
a[j] = rand() % 9;
}
int main()
{
const int size=5;
int a[size];
generateArray(a, size);
return 0;
}
Example 5: array syntax in c++
int bar [5] = { 10, 20, 30 };
Example 6: how to array in c++
int foo [5] = { 16, 2, 77, 40, 12071 };