NEW
Font size
WorksheetsC++ Operators and Control Flow Quiz
Total questions: 23
Worksheet time: 12mins
Which operator is used to assign a value to a variable?
==
=
!=
>=
What will be the output of the code: int x = 10, y = 3; cout 3 && 2 = 10);?
true
false
1
0
Which operator has the highest precedence?
+
*
=
==
What does != mean in C++?
Assign value
Equal to
Not equal to
Greater than
Which statement executes code only when a condition is true?
for
while
if
switch
What happens if break is missing in a switch case?
Program stops
Error occurs
Next case executes
Nothing happens
When does the else block execute?
When condition is true
When condition is false
Always
Never
Which loop checks the condition before execution?
do-while
for
while
Both for and while
Which loop executes at least once even if the condition is false?
for
while
do-while
switch
What is the output? for (int i = 1; i <= 3; i++) cout << i;
123
012
321
111
How many times will this loop execute? int i = 0; while (i < 5) { i++; }
4
5
6
Infinite
Which keyword skips the current loop iteration?
stop
exit
break
continue
Which loop is best when the number of repetitions is known?
while
do-while
for
switch
What happens when break is used inside a loop?
Skips one iteration
Restarts the loop
Exits the loop immediately
Ends the program
What is the result of the expression: 5 + 3 * 2?
10
16
11
8
Which keyword is used to define a function in C++?
method
void
function
def
What will be the output of the following code: int a = 5; if (a > 3) cout << "Greater";
Greater
No output
3
5
What is the purpose of the 'return' statement in a function?
To define a function
To return a value from the function
To exit the program
To create a loop
What will be the output of the following code: int a = 10; if (a < 5) cout << "Less"; else cout << "More";
Error
No output
More
Less
Which operator is used to compare two values for equality?
===
==
=
!=
What is the output of the following code: int x = 5; if (x == 5) cout << "Equal"; else cout << "Not Equal";
Equal
Error
No output
Not Equal
Which keyword is used to create a loop that iterates over a range of values?
for
loop
foreach
iterate
What will be the output of the following code: int a = 2, b = 3; cout << (a + b) * 2;
6
8
10
12
