Vidyalelo
C++ Programming · all questions

Control Flow Statements in C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

47

Questions

1/3

Page

Pick an option on a question to see the right answer and solution.

What is the syntax for the 'if' statement in C++?

Select an option to see the answer and solution.

What is the purpose of the 'else' statement in C++?

Select an option to see the answer and solution.

What is the correct syntax for the 'switch' statement in C++?

Select an option to see the answer and solution.

What will be the output of the following code: int x = 10; if (x > 5) cout << "Hello"; else cout << "Goodbye"; in C++?

Select an option to see the answer and solution.

What does the 'break' statement do in a loop in C++?

Select an option to see the answer and solution.

What is the correct syntax for the 'while' loop in C++?

Select an option to see the answer and solution.

What will be the output of the following code: int i = 0; while (i < 5) { cout << i << " "; i++; } in C++?

Select an option to see the answer and solution.

What is the purpose of the 'default' case in a 'switch' statement in C++?

Select an option to see the answer and solution.

What is the syntax for the 'do-while' loop in C++?

Select an option to see the answer and solution.

What will be the output of the following code: for (int i = 5; i >= 0; --i) { cout << i << " "; if (i == 3) break; } in C++?

Select an option to see the answer and solution.

In C++, what is the difference between the 'while' loop and the 'do-while' loop?

Select an option to see the answer and solution.

What is the purpose of the 'if-else if-else' statement in C++?

Select an option to see the answer and solution.

What will be the output of the following code: for (int i = 0; i < 3; ++i) { for (int j = 0; j < 2; ++j) { cout << i << j << " "; } }?

Select an option to see the answer and solution.

What is the syntax for the 'if-else' statement in C++?

Select an option to see the answer and solution.

What does the 'else if' statement allow in C++?

Select an option to see the answer and solution.

What is the output of the following code: int x = 10; if (x == 10) { cout << "x is 10"; } else { cout << "x is not 10"; } in C++?

Select an option to see the answer and solution.

What is the purpose of the 'continue' statement in a loop in C++?

Select an option to see the answer and solution.

What will be the output of the following code: int i = 0; while (i < 3) { cout << i << " "; i++; } in C++?

Select an option to see the answer and solution.

What is the purpose of the 'break' statement in a loop in C++?

Select an option to see the answer and solution.

What will be the output of the following code: for (int i = 0; i < 5; ++i) { if (i == 2) continue; cout << i << " "; } in C++?

Select an option to see the answer and solution.