0% found this document useful (0 votes)
1K views2 pages

CPP MCQ - Control Flow Statements PDF

The document contains a 12 question multiple choice quiz about control flow statements in C++. The questions cover topics like if/else statements, loops like while, for, do-while loops, break and continue statements, switch statements, and the ternary operator. The correct answers to each question are provided at the end.

Uploaded by

Blackk Worldz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views2 pages

CPP MCQ - Control Flow Statements PDF

The document contains a 12 question multiple choice quiz about control flow statements in C++. The questions cover topics like if/else statements, loops like while, for, do-while loops, break and continue statements, switch statements, and the ternary operator. The correct answers to each question are provided at the end.

Uploaded by

Blackk Worldz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MCQ in C++

Control Flow Statements

1. Which of the following can replace a simple if-else construct?


(A) Ternary operator (B) while loop (C) do-while loop (D) for loop

2. Which of the following is an entry-controlled loop?


(A) do-while loop (B) while loop (C) for loop (D) Both (B) and (C)

3. Which of the following is most suitable for a menu-driven program?


(A) do-while loop (B) while loop (C) for loop (D) All of these

4. Consider the following loop :


for(int i=0; i<5; i++) ;
What will be the value of i after this loop?
(A) It will give compilation error. (B) 5 (C) 6 (D) Some Garbage value

5. A switch construct can be used with which of the following types of variable?
(A) int (B) int, char (C) int, float, char (D) Any basic datatype

6. Which of the following must be present in switch construct?


(A) Expression in ( ) after switch (B) default
(C) case followed by value (D) All of these

7. What is the effect of writing a break statement inside a loop?


(A) It cancels remaining iterations. (B) It skips a particular iteration.
(C) The program terminates immediately. (D) Loop counter is reset.

8. What is the effect of writing a continue statement inside a loop?


(A) It cancels remaining iterations.
(B) It skips execution of statements which are written below it.
(C) The program terminates immediately.
(D) Loop counter is reset.

9. If the variable count exceeds 100, a single statement that prints “Too
many” is
(A) if (count<100) cout << “Too many”;
(B) if (count>100) cout >> “Too many”;
(C) if (count>100) cout << “Too many”;
(D) None of these.

10. The break statement causes an exit


(A) from the innermost loop only. (B) only from the innermost switch.
(C) from all loops & switches. (D) from the innermost loop or switch.

11. for (; ;)
(A) means the test which is done using some expression is always true
(B) is not valid
(C) will loop forever

YK
(D) should be written as for( )

12. Consider the following statements:


int x = 22,y=15;
x = (x>y) ? (x+y) : (x-y);
What will be the value of x after executing these statements?
(A) 22 (B) 37 (C) 7 (D) Error. Cannot be executed

ANS: 1. A 2. D 3. A 4. B 5. B 6. A 7. A 8. B
9. C 10. D 11. C 12. B

YK

You might also like