Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

499 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 391–400 of 499
Topics in C Programming
Q.391 Medium Control Flow
Which of the following is NOT a valid use of the goto statement in C?
A Jumping forward to a label
B Jumping backward to a label
C Jumping across function boundaries
D Jumping to an error handling block
Correct Answer:  C. Jumping across function boundaries
EXPLANATION

goto cannot jump across function boundaries. It can only jump within the same function to a labeled statement either forward or backward.

Take Test
Q.392 Medium Control Flow
What does this code segment output?
for (int i = 0; i < 5; i++) {
if (i % 2 == 0) continue;
printf("%d ", i);
}
A 1 3
B 0 2 4
C 1 3 5
D 0 1 2 3 4
Correct Answer:  A. 1 3
EXPLANATION

continue skips even numbers. Loop prints only odd values: 1 and 3.

Take Test
Q.393 Medium Control Flow
Determine the output:
int i = 0;
while (i < 3) {
printf("%d ", i++);
}
A 0 1 2
B 1 2 3
C 0 1 2 3
D Infinite loop
Correct Answer:  A. 0 1 2
EXPLANATION

i starts at 0. Loop prints i then increments: prints 0, then 1, then 2. When i becomes 3, condition fails.

Take Test
Q.394 Medium Control Flow
What is the output?
int n = 1;
do {
printf("%d ", n);
n++;
} while (n > 5);
A 1
B 1 2 3 4 5
C No output
D Infinite loop
Correct Answer:  A. 1
EXPLANATION

The do-while executes once (prints 1), then n becomes 2. Since 2 > 5 is false, the loop exits.

Take Test
Q.395 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.396 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.397 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.398 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.399 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.400 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
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