Exercise

1. In the following loop construct, which one is executed only once always.
    for(exp1; exp2; exp3)

A. exp1
B. exp3
C. exp1 and exp3
D. exp1, exp2 and exp3

View Answer

2. The continue statment cannot be used with

A. for
B. while
C. do while
D. switch

View Answer


3. Which keyword can be used for coming out of recursion?

A. return
B. break
C. exit
D. both A and B

View Answer


4. goto can be used to jump from main to within a function?

A. True
B. False

View Answer


5. Which of the following is an invalid if-else statement?

A. if (if (a == 1)){}
B. if (a){}
C. if ((char) a){}
D. if (func1 (a)){}

View Answer


6. Switch statement accepts.

A. int
B. char
C. long
D. All of the above

View Answer


7. Which loop is guaranteed to execute at least one time.

A. for
B. while
C. do while
D. None of the above

View Answer


8. A labeled statement consist of an identifier followed by

A. ;
B. :
C. ,
D. =

View Answer


9. do-while loop terminates when conditional expression returns?

A. One
B. Zero
C. Non - zero
D. None of the above

View Answer


10. c = (n) ? a : b; can be rewritten asexp1 ? exp2 : exp3;

A. if(n){c = a;}else{c = b;}
B. if(!n){c = a;}else{c = b;}
C. if(n){c = b;}else{c = a;}
D. None of the above

View Answer


11. For loop in a C program, if the condition is missing?

A. it is assumed to be present and taken to be false
B. it is assumed to be present and taken to the true
C. it result in a syntax error
D. execution will be terminated abruptly

View Answer


12.Which of the following statement about for loop is true ?

A. Index value is retained outside the loop
B. Index value can be changed from within the loop
C. Goto can be used to jump, out of the loop
D. All of these

View Answer


13.Using goto inside for loop is equivalent to using

A. Continue
B. Break
C. Return
D. None of the above

View Answer


14. If switch feature is used, then

A. Default case must be present
B. Default case, if used, should be the last case
C. Default case, if used, can be placed anywhere
D. None of the above

View Answer


15. Which of the following comments about for loop are correct ?

A. Using break is equivalent to using a goto that jumps to the statement immediately following the loop
B. Continue is used to by-pass the remainder of the current pass of the loop
C. If comma operator is used, then the value returned is the value of the right operand
D. All of the above

View Answer


16. In the context of "break" and "continue" statements in C, pick the best statement.

A. “break” and “continue” can be used in “for”, “while”, “do-while” loop body and “switch” body.
B. “break” and “continue” can be used in “for”, “while” and “do-while” loop body. But only “break” can be used in “switch” body.
C. “break” and “continue” can be used in “for”, “while” and “do-while” loop body. Besides, “continue” and “break” can be used in “switch” and “if-else” body.
D. “break” can be used in “for”, “while” and “do-while” loop body.

View Answer


17. In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make any references to each other.

A. Loop unrolling
B. Strength reduction
C. Loop concatenation
D. Loop jamming

View Answer



Discussion

* You must be logged in to add comment.