Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 231–240 of 303
Topics in C Programming
Q.231 Easy Control Flow
What is the primary difference between a while loop and a do-while loop?
A while checks condition before execution; do-while checks after
B do-while is faster than while
C while supports multiple conditions; do-while doesn't
D There is no functional difference
Correct Answer:  A. while checks condition before execution; do-while checks after
EXPLANATION

A do-while loop executes the body at least once before checking the condition. A while loop checks the condition first, so it may not execute at all.

Take Test
Q.232 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.233 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.234 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.235 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.236 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.237 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.238 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.239 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
In C programming, when you declare a variable as 'const int x = 5;', what happens if you try to modify it within the program?
A The compiler will generate a warning but allow modification at runtime
B The compiler will generate a compilation error and prevent modification
C The variable will be modified but will revert to original value after each operation
D The modification will be allowed only in the main() function
Correct Answer:  B. The compiler will generate a compilation error and prevent modification
EXPLANATION

The 'const' keyword creates a read-only variable. Once initialized, attempting to modify a const variable results in a compilation error (error: assignment of read-only variable). This is enforced at compile-time, not runtime.

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