Next: Review Questions Up: The for statement Previous: Summary

Multiple Choice Questions

for statements


Try to answer as many of the following Multi-choice questions as you can.

Do not panic if you make any errors. You can always start again by clicking on the "Restart" button, located at the bottom.


Your Details


Please enter your full name :


The Questions


Q1.

What is the value of i after the for statement below?

n = 100;
for ( i = 0; i < n; i++ ) {
 ...
}
 
99
100
101

Q2.

What are the first and last values of i output by this loop?

n = 20;
for ( i = 0; i < n; i++ ) {
  cout << i << endl;
}
 
0 and 19
1 and 19
0 and 20
1 and 20

Q3.

What are the first and last values of i output by this loop?

n = 15;
i = 0;
for( i = 0; i <= n; i++ ) {
  cout << i << endl;
}
 
0 and 15
1 and 14
1 and 15

Q4.

What is the last value of i output by this loop?

n = 27;
i = 0;
for( i = 0; i <= n; i+= 2 ) {
  cout << i << endl;
}
 
25
28
27
26


Once you have completed all the questions, and are quite happy with your answers. Then click on the "Submit Answers" button.

Clicking the "Restart" button will clear all your answers, ready to re-enter them.


Please send any comments about this page 



Next: Review Questions Up: The for statement Previous: Summary