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 761–770 of 1,000
Topics in C Programming
Q.761 Easy Control Flow
Which keyword is used to exit a loop prematurely in C?
A exit
B break
C return
D stop
Correct Answer:  B. break
EXPLANATION

The 'break' statement is used to exit or terminate a loop prematurely. 'exit' terminates the entire program, while 'return' exits functions.

Take Test
Q.762 Medium Control Flow
What will be the output of the following code?
int i = 0;
while(i < 3) {
printf("%d ", i++);
if(i == 2) continue;
}
A 0 1 2
B 0 1
C 0 2
D Infinite loop
Correct Answer:  A. 0 1 2
EXPLANATION

The loop prints 0, then i becomes 1. When i becomes 2, continue skips the rest but the loop continues. i becomes 3 and loop exits. Output: 0 1 2

Take Test
Q.763 Medium Control Flow
Which statement is best suited for implementing a menu-driven program with exact matching?
A if-else chain
B while loop
C switch statement
D for loop
Correct Answer:  C. switch statement
EXPLANATION

A switch statement is ideal for menu-driven programs where you match user input against specific cases. It's more efficient and readable than multiple if-else statements for this purpose.

Take Test
Q.764 Medium Control Flow
What is the scope of a variable declared in the initialization section of a for loop?
A Global scope
B Function scope
C Loop scope only
D File scope
Correct Answer:  C. Loop scope only
EXPLANATION

Variables declared in a for loop's initialization (e.g., for(int i=0; ...)) have block scope limited to that loop. They are not accessible outside the loop.

Take Test
Q.765 Hard Control Flow
What is the effect of using multiple break statements in nested loops?
A All nested loops terminate at once
B Only the innermost loop terminates
C Each break terminates its corresponding loop level
D Compilation error occurs
Correct Answer:  C. Each break terminates its corresponding loop level
EXPLANATION

Each break statement exits only its immediately enclosing loop. To exit multiple nested loops, you need one break for each level you want to exit.

Take Test
Q.766 Medium Control Flow
In a switch statement, case values must be of which type?
A Any type
B Integer or character constant
C String only
D Float or double
Correct Answer:  B. Integer or character constant
EXPLANATION

Switch case values must be constant integral expressions (int, char, enum). Floating-point values and strings (in C89/C90) are not allowed.

Take Test
Q.767 Easy Control Flow
Which control structure allows checking multiple conditions in sequence using else-if?
A for loop
B switch statement
C if-else-if chain
D do-while loop
Correct Answer:  C. if-else-if chain
EXPLANATION

The if-else-if chain allows testing multiple different conditions sequentially. switch is used for a single expression with multiple values.

Take Test
Q.768 Hard Control Flow
What happens when continue is used in a for loop with a post-increment expression?
A The increment is skipped
B The increment still executes
C Loop terminates
D Infinite loop occurs
Correct Answer:  B. The increment still executes
EXPLANATION

When continue is executed in a for loop, the post-increment (i++) still executes before the condition is checked again. Only the body statements after continue are skipped.

Take Test
Q.769 Medium Control Flow
In control flow, which statement is used to explicitly exit from a program?
A break
B exit()
C return
D halt
Correct Answer:  B. exit()
EXPLANATION

The exit() function terminates the entire program and returns control to the operating system. break exits loops, and return exits functions.

Take Test
Q.770 Medium Control Flow
How many times will a do-while loop execute if the condition is initially false?
A Zero times
B At least once
C Depends on the body
D Infinite times
Correct Answer:  B. At least once
EXPLANATION

A do-while loop executes the body at least once before checking the condition. Even if the condition is false, the body executes one time.

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