SYCS-135 Introduction to Programming

Quiz 9 - 11/18/99

 

��������������� Name:����������������������������������������� ID:

 

 

__A__1.���� The size of an array is established at compile time rather than at execution time.

 

A)������� True

B)������� False

 

��� D���� �2. Given a 5000-element array beta, which of the code fragments below could be used to print out the values of beta[0], beta[2], beta[4], and so forth? (All variables are of type int.)

 

A)����������� for (i = 0; i < 5000; i = i + 2)

cout << beta[i] << endl;

B)����������� for (i = 0; i < 2500; i++)

cout << beta[2*il << endl;

C)����������� for (i = 0; i < 2500; i++)

cout << beta[il*2 << endl;

D)����������� a and b above

E)����������� a, b, and c above

 

���� D ���3 . Given the declarations

 

const int NUM _ STUDENTS = 300;

��������� enum Colors {RED, BLACK, BROWN, BLOND, GRAY};

 

Which set of declarations below creates two parallel arrays, one that holds integer ID numbers and one that holds student hair colors?

 

A)����������� int studentID[NUM_STUDENTS];

int hairColor[NUM_STUDENTS];

B)����������� int studentID[NUM_STUDENTS];

int hairColor[Colors];

C)����������� int studentID[Colors];

int hairColor[Colors],

D)����������� int studentID[NUM_STUDENTS];

Colors hairColor[NUM_STUDENTS];

 

���� C��� ��4. Given the declaration

 

float costOfGoods[8][2][7];

 

��������������� how many float components does costOfGoods have?

 

A)����������� 70

B)����������� 72

C)����������� 112

D)����������� 17

E)����������� 8

 

5.������������ Given the declarations

 

��������������� enum Colors {RED, ORANGE, YELLOW, GREEN, BLUE};

��������������� �float waveLength[5]; // To be indexed by values of

������������������������������� �� // type Colors

��������������� write a statement to print the third component of the waveLength array:

��������������� cout << wavelength[2] �or cout << wavelength[YELLOW];