Professional Documents
Culture Documents
Keth Iralex Cabalda BES 043 (Module 16)
Keth Iralex Cabalda BES 043 (Module 16)
Static Arrays
1. Write a program that will keep track of the score of the players solving for the sum of two (given by
the program) numbers. The two (max of 2-digit) numbers are randomly generated. There will be a
maximum of ten players, that means 2 can play, 4 players can play or 7 players. The player takes turn
answering while the program is tracking and displaying their score. The program ends if one of the
players reach the score 10.
1. If an array int scores [ ] = {100, 20, 50, 80, 11}; is declared, what is the value of scores[2]?
- 50
2. What is wrong with the declaration and initialization below? char choices[4] = {‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’,
‘g’};
- too many initializers for 'char [4]'
3. If an array is declared as int stars [3] = {100, 20, 50}; what is wrong with the statement below? for (int
n=1 ; n<9 ; ++n ) stars [n] = n ;
- “n<9 was not declared in this scope”
4. What is the output for the following fragment of code?I
int data2[10] = {7, 5, 12, 4, 0, 6, 5, 0, 2, 98};
int x=0, t=0;
while(data2[x]!=0){
cout<<data2[x]<< ‘ ‘;
x+=2;
t +=data2[x];
if(t>=20) break;
}