Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

291 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 211–220 of 291
Topics in C Programming
Q.211 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.

Test
Q.212 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.

Test
Q.213 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.

Test
Q.214 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.

Test
Q.215 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.

Test
Q.216 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.

Test
Q.217 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.

Test
Q.218 Easy Control Flow
What will be the result?
for(int i = 1; i
A 1 2 3 4
B 1 2
C 1 2 3
D 2 3 4
Correct Answer:  B. 1 2
EXPLANATION

When i=3, break executes and exits the loop immediately. Only i=1 and i=2 are printed. Output: 1 2

Test
Q.219 Easy Control Flow
In the ternary operator (? :), what happens if the condition is false?
A The first expression is evaluated
B The second expression is evaluated
C Both expressions are evaluated
D No expression is evaluated
Correct Answer:  B. The second expression is evaluated
EXPLANATION

The ternary operator syntax is: condition ? true_expr : false_expr. If condition is false, false_expr is evaluated.

Test
Q.220 Easy Control Flow
Analyze the code: What happens when condition in if statement is false?
if(0) { statements; } else { statements; }
A Program terminates
B Else block executes
C Infinite loop occurs
D Syntax error
Correct Answer:  B. Else block executes
EXPLANATION

When the if condition is false (0 is false in C), the else block executes. This is basic if-else control flow.

Test
IGET
IGET AI
Online · Exam prep assistant
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