Friday 29 March 2013

Quiz 3: C++ Loop Statements


C++ Programming Quiz Solutions: Loops


1. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1

2. When does the code block following while(x<100) execute?
A. When x is less than one hundred
B. When x is greater than one hundred
C. When x is equal to one hundred
D. While it wishes

3. Which is not a loop structure?
A. For
B. Do while
C. While
D. Repeat Until

4. How many times is a do while loop guaranteed to loop?
A. 0
B. Infinitely
C. 1
D. Variable



Blog Author: Vijay Kumar

Quiz 2: C++ If Statements

C++ Programming Quiz: If statements

1. Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above

2. Which of the following is the boolean operator for logical-and?
A. &
B. &&
C. |
D. |&

3. Evaluate !(1 && !(0 || 1)).
A. True
B. False
C. Unevaluatable

4. Which of the following shows the correct syntax for an if statement?
A. if expression
B. if { expression
C. if ( expression )
D. expression if


Blog Author: Vijay Kumar