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 781–790 of 1,000
Topics in C Programming
Q.781 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.782 Easy Control Flow
In C, which control flow statement is used to terminate a loop prematurely?
A break
B continue
C exit
D halt
Correct Answer:  A. break
EXPLANATION

The 'break' statement is used to exit or terminate a loop immediately. 'continue' skips the current iteration, 'exit' terminates the entire program.

Take Test
Q.783 Hard Control Flow
What is the output of this complex nested control flow?
int x = 1, y = 2;
if (x < y) {
x++; y--;
if (x == y)
printf("Equal");
else
printf("NotEqual");
}
A Equal
B NotEqual
C No output
D Compilation error
Correct Answer:  A. Equal
EXPLANATION

x=1, y=2. Since 1 < 2, x becomes 2 and y becomes 1. Now x != y, but after operations x=2, y=1. Wait: x++ makes x=2, y-- makes y=1. So x==y is false, printing 'NotEqual'. Rechecking: 1 < 2 is true, so enter if. x becomes 2, y becomes 1. 2 == 1 is false, so else executes, printing 'NotEqual'.

Take Test
Q.784 Easy Control Flow
Which statement is used to skip remaining iterations and move to next iteration?
A skip
B continue
C next
D return
Correct Answer:  B. continue
EXPLANATION

continue is the C keyword that jumps to the next iteration of the loop.

Take Test
Q.785 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.786 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.787 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.

Take Test
Q.788 Hard Control Flow
What is the output of this program?
for (int i = 1; i
A 1 2\n 2 4\n 3 6
B 12 24 36
C 123456
D Error
Correct Answer:  A. 1 2\n 2 4\n 3 6
EXPLANATION

Nested loops: outer i=1,2,3; inner j=1,2. Prints products: 1*1=1, 1*2=2 (newline), 2*1=2, 2*2=4 (newline), etc.

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

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