< previous page page_607 next page >

Page 607
cin >> grade[2];
reads the next nonwhitespace character from the input stream and stores it into the component in grade indexed by 2;
grade[3] = 'A';
assigns the character 'A' to the component in grade indexed by 3;
idNumber = 5;
assigns 5 to the index variable idNumber;
grade[idNumber] = 'C';
assigns the character 'C' to the component of grade indexed by idNumber (that is, by 5); and
for (idNumber = 0; idNumber < NUM_STUDENTS; idNumber++)
    cout << grade[idNumber];
loops through the grade array, printing each component. For this loop, the output would be FBCAFCAACB. And, finally,
for (idNumber = 0; idNumber < NUM_STUDENTS; idNumber++)
    cout << "Student " << idNumber
         << " Grade " << grade[idNumber] << endl;
loops through grade, printing each component in a more readable form. idNumber is used as the index, but it also has semantic content-it is the student's identification number. The output would be
Student 0 Grade F
Student 1 Grade B
  .
  .
  .
Student 9 Grade B

 
< previous page page_607 next page >