MCQ PORTAL

Back to All Topics

Branching and Looping

Showing 20 of 20 questions in this topic

Start Practice Mode

Answer Green MarksON

Correct answers are highlighted in green

C032Branching and Looping • Loops
Most ImportantMedium

Q1.Which loop is guaranteed to execute its body AT LEAST ONCE?

A
for
B
while
C
do-while
Correct answer
D
if
C034Branching and Looping • Loops
Most ImportantEasy

Q2.How many times does this loop run? for(i = 1; i <= 5; i++)

A
4 times
B
5 times
Correct answer
C
6 times
D
infinite
C035Branching and Looping • continue
Most ImportantMedium

Q3.Which statement skips the current iteration and moves to the next one in a loop?

A
break
B
continue
Correct answer
C
skip
D
return
C036Branching and Looping • break
Most ImportantEasy

Q4.The break statement inside a loop:

A
skips one iteration
B
terminates the loop immediately
Correct answer
C
restarts the loop
D
does nothing
C037Branching and Looping • while loop
Most ImportantMedium

Q5.What is the output? int i = 0; while(i < 3){ printf("%d", i); i++; }

A
012
Correct answer
B
123
C
0123
D
infinite loop
C038Branching and Looping • if-else
Most ImportantEasy

Q6.In an if-else statement, the else block executes when the condition is:

A
true
B
false
Correct answer
C
always
D
never
C040Branching and Looping • for loop
Most ImportantEasy

Q7.What is the correct syntax of a for loop?

A
for(init; condition; update)
Correct answer
B
for(condition; init; update)
C
for(init, condition, update)
D
for(update; condition; init)
C120Branching and Looping • for loop
Most ImportantEasy

Q8.How many times does this loop run? for(i = 0; i < 10; i++)

A
9
B
10
Correct answer
C
11
D
infinite
C124Branching and Looping • break
Most ImportantEasy

Q9.Which keyword immediately transfers control out of a loop?

A
continue
B
break
Correct answer
C
return
D
exit
C127Branching and Looping • while loop
Most ImportantMedium

Q10.What is the output? int i = 5; while(i > 0){ printf("%d", i); i--; }

A
12345
B
54321
Correct answer
C
5
D
01234
C033Branching and Looping • Loops
ImportantMedium

Q11.Which of the following is an ENTRY-CONTROLLED loop?

A
do-while
B
while
Correct answer
C
goto
D
switch
C039Branching and Looping • if condition
ImportantMedium

Q12.What is printed? if(5) printf("Yes"); else printf("No");

A
Yes
Correct answer
B
No
C
error
D
nothing
C121Branching and Looping • for loop
ImportantMedium

Q13.How many times does this loop run? for(i = 1; i <= 10; i += 2)

A
10
B
4
C
5
Correct answer
D
6
C122Branching and Looping • Empty body
ImportantHard

Q14.What is the output? for(i = 0; i < 3; i++); printf("%d", i);

A
012
B
3
Correct answer
C
0
D
2
C123Branching and Looping • do-while
ImportantMedium

Q15.How many times does the body of do { ... } while(0); execute?

A
0 times
B
1 time
Correct answer
C
infinite
D
depends
C125Branching and Looping • Nested loops
ImportantMedium

Q16.An outer loop runs 3 times and its inner loop runs 4 times each. How many times does the inner body run in total?

A
7
B
12
Correct answer
C
3
D
4
C126Branching and Looping • while loop
ImportantEasy

Q17.How many times does the body of while(0) { ... } execute?

A
0 times
Correct answer
B
1 time
C
infinite
D
10 times
C128Branching and Looping • do-while
ImportantMedium

Q18.What is the output? int i = 1; do{ printf("%d", i); i++; } while(i <= 3);

A
12
B
123
Correct answer
C
1234
D
1
C041Branching and Looping • Infinite loop
OtherMedium

Q19.The loop for( ; ; ) will:

A
give a syntax error
B
run exactly once
C
run as an infinite loop
Correct answer
D
never run
C129Branching and Looping • if-else
OtherMedium

Q20.In a nested if-else without braces, an else matches with the:

A
first if
B
nearest unmatched if
Correct answer
C
last statement
D
outer block