Professional Documents
Culture Documents
CS111 Quiz 10
CS111 Quiz 10
CS111 Quiz 10
State Finished
Completed on Sunday, 12 June 2022, 10:10 PM
Time taken 5 mins 52 secs
Mark 1.00 out of 1.00 (100%)
Question 1
Correct
Mark 0.10 out of 0.10
Flag question
Question text
How to declare an array values of type double with 7 elements?
double values[7];
Answer:
Feedback
The correct answer is: double values[7];
Question 2
Correct
Mark 0.10 out of 0.10
Flag question
Question text
Suppose you want to change the 5th element of array values to value 37. Please
complete the following code:
values[Answer
]=37;
Question 3
Correct
Mark 0.10 out of 0.10
Flag question
Question text
What number will the following code snippet print?
int numbers[8] = { 34, 42, 6, 11, 29, 1, 89, 62};
cout << numbers[7];
62
Answer:
Feedback
The correct answer is: 62
Question 4
Correct
Mark 0.10 out of 0.10
Flag question
Question text
Consider the following code snippet:
const int CAPACITY = 100;
double values[CAPACITY];
int size = 0;
double input;
while (cin >> input){
if (size < CAPACITY){
values[size] = input;
size++;
}
}
Suppose the user enters the values 23, 32, 17, 18, 9, 9, before he enters 'q'
What will be te value of size?
6
Answer:
Feedback
The correct answer is: 6
Question 5
Correct
Mark 0.40 out of 0.40
Flag question
Question text
Which of the following is true or false?
All elements of an array are of the same type. true
Answer 1
Question 6
Correct
Mark 0.20 out of 0.20
Flag question
Question text
Consider the following code snippet
1 const int N = 5;
2 double pops[N] = {23,12};
3 for(int i=0; i<=N;i++){
4 cout << pops[i] << endl;
5 }
Which of the following statements is true about line 2 and line 3?
Line 2 is correct
Answer 1
Line 3 has an array bounds error. Counter i should be strictly less than N.
Answer 2
Feedback
The correct answer is: Line 2 → is correct, Line 3 → has an array bounds error.
Counter i should be strictly less than N.