sign in
 
   
 
 
 
   
  Multiple choice questions and answers for  
  Programming Language and C/C++  
   
 
1. The break statement is used to exit from:
     
  a. a DO loop.
  b. a FOR loop.
  c. a SWITCH statement.
  d. all of above.
     
    Answer: d. all of above.
   
     
 
 
2. In which statements, does a CONTINUE statement cause the control to go directly to the test condition and then continue the looping process?
     
  a. FOR and WHILE.
  b. WHILE and IF-ELSE.
  c. DO-WHILE and IF-ELSE.
  d. While and DO-WHILE.
     
    Answer: d. While and DO-WHILE.
   
In a do or while loop, the next iteration starts by re-evaluating the controlling expression of the do or while statement.

In a for loop (using the syntax for(init-expr; cond-expr; loop-expr)), continue causes loop-expr to be executed. Then cond-expr is re-evaluated and, depending on the result, the loop either terminates or another iteration occurs.

     
 
 
3. The advantage of a SWITCH statement over an ELSE-IF statement:
     
  a. A default condition can be used in the SWITCH.
  b. The SWITCH is easier to understand.
  c. Several different condition can cause one set of statements to be executed in a SWITCH.
  d. Several different statements can be executed in a SWITCH.
     
    Answer: b. The SWITCH is easier to understand.
   
     
 
 
4. The comma operator (,) is primarily used in conjunction with:
     
  a. FOR statement.
  b. IF-ELSE statement.
  c. DO-While statement.
  d. All of above.
     
    Answer: a. FOR statement.
   
     
 
 
5. The GOTO statement is used:
     
  a. to permit two different expressions to appear in situation where only one expression would ordinarily used.
  b. to terminate loops or to exit from a switch.
  c. an unconditional transfer of control to a named label.
  d. to carry out a logical test and then take one of two possible actions, depending upon the outcome of a test.
     
    Answer: c. an unconditional transfer of control to a named label.