Program to Test Array
Initializations
% cat arrayTest.cpp
// test array features
#include<iostream>
using namespace std;
int main()
{
const int NUM_EL = 5;
int i;
// too few numbers in initialization list
int scores[NUM_EL] = {97};
// too many numbers
//int scores[NUM_EL] = {97, 82, 57, 98, 88, 99, 100};
cout << scores[4] << endl;
// out-of-bounds assignment
// scores[1000] = 55;
return 0;
}
% g++ arrayTest.cpp
% a.out
0
|