CSCI 240 - Quiz Questions - Week 4

1. (2) Which of the following increments x by 1?
a. 1++;
b. x + 1;
c. x = 1;
d. x += 1;
e. x+;

2. (3) Name and describe the three control structures we will study in this course.

3. (3) Name the 3 C++ statements used to create a loop.

4. (4) What will the following code display on the screen and where will it display?

for (i = 0; i < 5; i++)
  cout << "\n";
  cout << i;

5. (4) Write a for loop to display the first 5 multiples of 10 on one line.   (10 20 30 40 50)

6. (4) Write a while loop to display the first 5 multiples of 10 on one line.   (10 20 30 40 50)

7. (2) When is the 3rd subexpression in  for (--; --; --) statement executed?

8. (4) Write a decision statement to test if a number is even or not.  If it is, print "even".  If it is not, add 1 to it and print "it was odd, but now it's not".

9. (2) Why is a while loop described as "top-driven"

10. (3) If you write a read-loop to process an unknown number of values using the while construct, and if there is one read before the while instruction there will also be one
a. at the top of the body of the loop
b. at the bottom of the body of the loop
c. in the middle of the body of the loop
d. there are no other reads