Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 211–220 of 303
Topics in C Programming
Q.211 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.212 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.213 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
Q.214 Easy Control Flow
Which control flow statement allows jumping to a labeled location in C?
A jump
B goto
C skip
D branch
Correct Answer:  B. goto
EXPLANATION

goto statement allows unconditional jump to a labeled location. Though generally discouraged, it's valid in C and sometimes used for error handling.

Take Test
Q.215 Easy Control Flow
In a switch statement, if a case label is missing the break statement, what occurs?
A Compilation error
B Runtime error
C Fall-through to next case (no error)
D Automatic break is inserted by compiler
Correct Answer:  C. Fall-through to next case (no error)
EXPLANATION

Missing break causes fall-through behavior where execution continues to the next case label until a break or end of switch is encountered.

Take Test
Q.216 Easy Control Flow
What is the primary difference between while and do-while loops?
A while is faster than do-while
B do-while executes the body at least once before checking condition
C while can use break statement but do-while cannot
D do-while requires a semicolon after the closing parenthesis
Correct Answer:  B. do-while executes the body at least once before checking condition
EXPLANATION

do-while loop checks the condition after executing the loop body, ensuring at least one execution. while loop checks before executing.

Take Test
Q.217 Easy Control Flow
Which of the following control flow statements will cause a compilation error in C?
A break; used outside any loop or switch
B continue; used inside a for loop
C return; used inside main function
D goto label; where label is defined later
Correct Answer:  A. break; used outside any loop or switch
EXPLANATION

break and continue statements can only be used within loops or switch statements. Using break outside these constructs results in a compilation error.

Take Test
Q.218 Easy Control Flow
What value does the ternary operator return?
int result = (5 > 3) ? 10 : 20;
A 5
B 3
C 10
D 20
Correct Answer:  C. 10
EXPLANATION

The condition (5 > 3) is true, so the ternary operator evaluates and returns the true expression value: 10.

Take Test
Q.219 Easy Control Flow
Which statement best describes the difference between break and continue?
A break exits the loop; continue skips the current iteration
B Both terminate the loop
C continue exits; break skips iteration
D They are identical in functionality
Correct Answer:  A. break exits the loop; continue skips the current iteration
EXPLANATION

break completely exits/terminates the loop. continue skips the rest of current iteration and jumps to the next iteration.

Take Test
Q.220 Easy Control Flow
What is printed by this code?
int x = 1, y = 2;
if(x > y) printf("A");
else if(x < y) printf("B");
else printf("C");
A A
B B
C C
D AB
Correct Answer:  B. B
EXPLANATION

Since x=1 and y=2, x>y is false, but x<y is true, so 'B' is printed. The else if condition matches.

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