C Programming — Control Flow
C language from basics to advanced placement prep
36 Questions 10 Topics Take Test
Advertisement
Showing 1–10 of 36 questions in Control Flow
Q.1 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
Q.2 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.3 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
Q.4 Easy Control Flow
What is the purpose of the ternary operator (? :) in C?
A To replace multiple for loops
B To provide a shorthand for if-else statements
C To handle exceptions
D To declare three variables at once
Correct Answer:  B. To provide a shorthand for if-else statements
EXPLANATION

The ternary operator (condition ? true_value : false_value) is a concise alternative to if-else for simple conditional assignments.

Take Test
Q.5 Easy Control Flow
In which scenario would a do-while loop be preferred over a while loop?
A When the loop must execute at least once
B When the condition is checked before execution
C When nested loops are involved
D When break statement is used
Correct Answer:  A. When the loop must execute at least once
EXPLANATION

do-while executes the body first, then checks the condition, ensuring at least one execution.

Take Test
Advertisement
Q.6 Easy Control Flow
Which looping construct in C allows initialization, condition, and increment to be placed in a single line?
A while loop
B do-while loop
C for loop
D None of the above
Correct Answer:  C. for loop
EXPLANATION

The for loop syntax is for(init; condition; increment) allowing all three components in one statement.

Take Test
Q.7 Easy Control Flow
In a nested loop structure, which statement is used to skip the current iteration of the innermost loop only?
A break
B continue
C return
D exit()
Correct Answer:  B. continue
EXPLANATION

continue skips the current iteration of the innermost loop and moves to the next iteration, while break exits the loop entirely.

Take Test
Q.8 Easy Control Flow
In a for loop for(int i = 0; i < 5; i++), at what point does the increment happen?
A Before checking the condition
B After executing the loop body
C At the beginning before first iteration
D During condition evaluation
Correct Answer:  B. After executing the loop body
EXPLANATION

For loop order: initialization → check condition → execute body → increment → repeat from condition check.

Take Test
Q.9 Easy Control Flow
Which statement is true about the goto statement in modern C programming?
A It is completely removed from C standards
B It is legal but generally discouraged for code clarity
C It is mandatory for error handling
D It automatically optimizes loop performance
Correct Answer:  B. It is legal but generally discouraged for code clarity
EXPLANATION

goto is valid in C but discouraged in modern programming as it reduces code readability. However, it has legitimate uses in cleanup code and error handling.

Take Test
Q.10 Easy Control Flow
In the ternary operator expression (condition ? expr1 : expr2), if condition is true, which expression evaluates?
A Both expr1 and expr2
B Only expr1
C Only expr2
D Neither, condition is returned
Correct Answer:  B. Only expr1
EXPLANATION

Ternary operator is short-circuit. If condition is true, expr1 evaluates and expr2 is skipped. If false, expr2 evaluates and expr1 is skipped.

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