void display(int v[], int n) {
for (int i = 0; i < n; i++) {
cout << setw(4) << v[i];
}
cout << endl;
}
|
Suppose we initialize an array and display it like this:
const int SIZE = 10;
int a[SIZE];
for (int i = 0; i < SIZE; i++) {
a[i] = i*i;
}
display(a, SIZE);
|
Output:
0 1 4 9 16 25 36 49 64 81