Home Subjects C Programming Control Flow

C Programming
Control Flow

C language from basics to advanced placement prep

36 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 31–36 of 36
Topics in C Programming
Q.31 Easy Control Flow
What is the behavior of goto in C?
A It transfers control to a labeled statement
B It exits the program
C It skips the next statement
D It is not part of C standard
Correct Answer:  A. It transfers control to a labeled statement
EXPLANATION

goto transfers program control to a labeled location, though it's discouraged for code readability.

Test
Q.32 Easy Control Flow
Analyze the ternary operator: int x = (5 > 3) ? 10 : 20; What is the value of x?
A 10
B 20
C 1
D Compilation error
Correct Answer:  A. 10
EXPLANATION

Since 5 > 3 is true, the ternary operator returns 10, so x = 10.

Test
Q.33 Easy Control Flow
What is the difference between 'break' and 'continue' in loops?
A break exits the loop, continue skips to next iteration
B continue exits the loop, break skips to next iteration
C Both are identical
D break is only for switch, continue is only for loops
Correct Answer:  A. break exits the loop, continue skips to next iteration
EXPLANATION

break terminates the loop entirely, while continue jumps to the next iteration without executing remaining statements.

Test
Q.34 Easy Control Flow
What is the output of this code?
for (int i = 0; i < 3; i++)
printf("%d ", i);
A 0 1 2
B 1 2 3
C 0 1 2 3
D Nothing prints
Correct Answer:  A. 0 1 2
EXPLANATION

The loop runs from i=0 to i=2 (i < 3), printing '0 1 2 '.

Test
Q.35 Easy Control Flow
Which of the following is NOT a valid control flow statement in C?
A switch
B foreach
C while
D for
Correct Answer:  B. foreach
EXPLANATION

foreach is not a standard C control flow statement. C has if-else, switch, for, while, do-while, and goto.

Test
Q.36 Easy Control Flow
What will be the output of the following C code?
int x = 5;
if (x > 3)
printf("A");
else
printf("B");
A A
B B
C Compilation error
D No output
Correct Answer:  A. A
EXPLANATION

Since x = 5 and 5 > 3 is true, the if block executes and prints 'A'.

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