C Programming Multiple Choice Question - Structure And Loops
This section focuses on the "Structure And Loops" of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
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
Ans : A
Explanation: Expression exp1 is executed only once since this is used for initialization
2. The continue statment cannot be used with
A. for
B. while
C. do while
D. switch
View Answer
Ans : D
Explanation: continue is used to skip the statments and can not be used with switch
3. Which keyword can be used for coming out of recursion?
A. return
B. break
C. exit
D. both A and B
View Answer
Ans : A
Explanation: Return is used for coming out of recursion
4. goto can be used to jump from main to within a function?
A. TRUE
B. FALSE
C. May Be
D. Can't Say
View Answer
Ans : B
Explanation: goto statement in C programming provides an unconditional jump from the 'goto' to a labeled statement in the same function.
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
Ans : A
Explanation: None
6. Switch statement accepts.
A. int
B. char
C. long
D. All of the above
View Answer
Ans : D
Explanation: switch statment accepts all int , char and long .
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
Ans : C
Explanation: In do while first the statements in the body are executed then the condition is checked. If the condition is true then once again statements in the body of do while are executed.
8. A labeled statement consist of an identifier followed by
A. ;
B. :
C. ,
D. =
View Answer
Ans : B
Explanation: The label is an identifier. When goto statement is encountered, control of the program jumps to label: and starts executing the code.
9. do-while loop terminates when conditional expression returns?
A. One
B. Zero
C. Non - zero
D. None of the above
View Answer
Ans : B
Explanation: zero indicate False which terminate the loop .
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
Ans : A
Explanation: None.
Also check :
Discussion