Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

1,000 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 791–800 of 1,000
Topics in C Programming
Q.791 Medium Control Flow
What is printed by this code?
int x = 5;
while (x-- > 0)
printf("%d ", x);
A 5 4 3 2 1 0
B 4 3 2 1 0
C 5 4 3 2 1
D 4 3 2 1
Correct Answer:  B. 4 3 2 1 0
EXPLANATION

x-- returns 5 first, then decrements to 4. Loop runs while x > 0, printing 4, 3, 2, 1, 0.

Take Test
Q.792 Medium Control Flow
How many times will this loop execute?
for (int i = 0; i < 5; ++i) {
if (i == 2) continue;
if (i == 4) break;
}
A 2 times
B 3 times
C 4 times
D 5 times
Correct Answer:  C. 4 times
EXPLANATION

Loop runs for i=0,1,2,3. When i=4, break is executed. The body executes 4 times (iterations for i=0,1,2,3).

Take Test
Q.793 Medium Control Flow
What is the output of this switch statement?
int x = 2;
switch(x) {
case 1: printf("One"); break;
case 2: printf("Two");
case 3: printf("Three"); break;
default: printf("Other");
}
A Two
B TwoThree
C Three
D TwoThreeOther
Correct Answer:  B. TwoThree
EXPLANATION

Case 2 matches. Since there's no break after case 2, fall-through occurs to case 3, printing 'TwoThree'.

Take Test
Q.794 Medium Control Flow
What does the following nested if-else produce?
int a = 10, b = 20;
if (a > b)
if (b > 0)
printf("X");
else
printf("Y");
A X
B Y
C XY
D No output
Correct Answer:  B. Y
EXPLANATION

The else clause pairs with the inner if. Since a > b is false, the else block executes printing 'Y'.

Take Test
Q.795 Medium Control Flow
What is the output?
for (int i = 1; i
A 1 2
B 1 2 3
C 1 2 3 4 5
D 2 3 4
Correct Answer:  A. 1 2
EXPLANATION

When i becomes 3, break is executed, exiting the loop. So only 1 and 2 are printed.

Take Test
Q.796 Medium Control Flow
What will be printed?
int x = 0;
if (x = 5)
printf("True");
else
printf("False");
A True
B False
C Compilation error
D Undefined behavior
Correct Answer:  A. True
EXPLANATION

x = 5 assigns 5 to x and evaluates to 5 (non-zero), which is true. So 'True' is printed.

Take Test
Q.797 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.

Take Test
Q.798 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 '.

Take Test
Q.799 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.

Take Test
Q.800 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'.

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