C Programming — Control Flow
C language from basics to advanced placement prep
100 Questions 10 Topics Take Test
Advertisement
Showing 1–10 of 100 questions in Control Flow
Q.1 Hard Control Flow
Consider the code:
int sum = 0;
for(int i = 1; i
A 25
B 55
C 30
D 45
Correct Answer:  A. 25
EXPLANATION

The loop adds only odd numbers (1,3,5,7,9) due to the continue statement when i is even. Sum = 1+3+5+7+9 = 25.

Take Test
Q.2 Medium Control Flow
Which of the following statements about the switch-case construct is INCORRECT?
A The default case is mandatory in every switch statement
B Each case must end with a break statement to prevent fall-through
C Multiple cases can have the same code block if break is omitted
D The switch expression is evaluated only once
Correct Answer:  A. The default case is mandatory in every switch statement
EXPLANATION

The default case is optional in a switch statement. It executes when no case matches, but it is not mandatory. All other statements are correct properties of switch-case.

Take Test
Q.3 Medium Control Flow
Analyze this code:
for(int i = 0; i < 5; i++) {
if(i == 2) continue;
if(i == 3) break;
printf("%d ", i);
}
What is the output?
A 0 1
B 0 1 2 3
C 0 1 3
D 0 1 2
Correct Answer:  A. 0 1
EXPLANATION

When i=0: prints 0. When i=1: prints 1. When i=2: continue skips printf. When i=3: break terminates the loop. Output is '0 1'.

Take Test
Q.4 Medium Control Flow
In nested loops, if an inner loop contains a break statement, what happens?
A Only the inner loop terminates; the outer loop continues
B Both inner and outer loops terminate
C The entire program terminates
D The break statement is ignored in nested loops
Correct Answer:  A. Only the inner loop terminates; the outer loop continues
EXPLANATION

The break statement only exits the innermost loop that contains it. It does not affect the outer loop's execution. The outer loop will continue its iterations normally.

Take Test
Q.5 Easy Control Flow
Consider the following code snippet:
int x = 5;
do {
printf("%d ", x);
x--;
} while(x > 0);
What will be the output?
A 5 4 3 2 1
B 4 3 2 1
C 5 4 3 2 1 0
D No output
Correct Answer:  A. 5 4 3 2 1
EXPLANATION

The do-while loop executes at least once. x starts at 5, prints 5, decrements to 4, and continues while x > 0. Loop executes for x = 5,4,3,2,1 and exits when x becomes 0.

Take Test
Advertisement
Q.6 Easy Control Flow
What is the primary difference between 'break' and 'continue' statements in C loops?
A break exits the loop entirely, while continue skips the current iteration and proceeds to the next
B continue exits the loop entirely, while break skips the current iteration
C Both statements perform identical functions
D break skips iterations, continue terminates the program
Correct Answer:  A. break exits the loop entirely, while continue skips the current iteration and proceeds to the next
EXPLANATION

break statement terminates the loop completely, whereas continue statement skips the remaining statements in the current iteration and moves to the next iteration of the loop.

Take Test
Q.7 Medium Control Flow
In a for loop with multiple break statements in different conditions, which break will be executed?
A Only the first break encountered
B All break statements execute
C The break statement whose condition is true
D None of them execute unless the loop condition fails
Correct Answer:  C. The break statement whose condition is true
EXPLANATION

Only the break statement whose associated if condition evaluates to true will be executed, exiting the loop immediately.

Take Test
Q.8 Medium Control Flow
What is the output of this code?
char ch = 'B';
switch(ch) {
case 'A':
case 'B':
case 'C': printf("Vowel");
break;
default: printf("Consonant");
}
A Vowel
B Consonant
C No output
D Compilation error
Correct Answer:  A. Vowel
EXPLANATION

ch='B' matches case 'B', which has no statements. Execution falls through to case 'C' which has no statements, then prints 'Vowel' and breaks.

Take Test
Q.9 Hard Control Flow
What will be printed?
int i = 0, j = 0;
for(i = 0; i < 3; i++) {
for(j = 0; j < 3; j++) {
if(i + j == 2) break;
printf("%d%d ", i, j);
}
}
A 00 01 10
B 00 01 10 11 20 21
C 00 01 11 20 21
D 00 10 20
Correct Answer:  A. 00 01 10
EXPLANATION

Inner break only exits the inner loop. i=0,j=0: prints 00; i=0,j=1: prints 01, breaks when j=2; i=1,j=0: prints 10, breaks when j=1; i=2,j=0: breaks immediately.

Take Test
Q.10 Easy Control Flow
Which statement is true about the goto statement in modern C programming practices?
A It should be used for all control flow
B It is completely banned in C
C It is legal but generally avoided due to code clarity concerns
D It can only be used within switch statements
Correct Answer:  C. It is legal but generally avoided due to code clarity concerns
EXPLANATION

goto is legal in C but discouraged as it can create hard-to-follow code paths. It's acceptable in limited contexts like error handling.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips