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 751–760 of 1,000
Topics in C Programming
Q.751 Easy Control Flow
What is printed by this code?
int x = 1, y = 2;
if(x > y) printf("A");
else if(x < y) printf("B");
else printf("C");
A A
B B
C C
D AB
Correct Answer:  B. B
EXPLANATION

Since x=1 and y=2, x>y is false, but x<y is true, so 'B' is printed. The else if condition matches.

Take Test
Q.752 Medium Control Flow
In a switch statement with integer cases, can a case have a floating-point constant?
A Yes, always
B No, never
C Only if explicitly cast
D Only in newer C standards
Correct Answer:  B. No, never
EXPLANATION

Case labels must be constant integral expressions (int, char, etc.). Floating-point constants are not allowed as case labels.

Take Test
Q.753 Easy Control Flow
What will be the result?
for(int i = 1; i
A 1 2 3 4
B 1 2
C 1 2 3
D 2 3 4
Correct Answer:  B. 1 2
EXPLANATION

When i=3, break executes and exits the loop immediately. Only i=1 and i=2 are printed. Output: 1 2

Take Test
Q.754 Easy Control Flow
In the ternary operator (? :), what happens if the condition is false?
A The first expression is evaluated
B The second expression is evaluated
C Both expressions are evaluated
D No expression is evaluated
Correct Answer:  B. The second expression is evaluated
EXPLANATION

The ternary operator syntax is: condition ? true_expr : false_expr. If condition is false, false_expr is evaluated.

Take Test
Q.755 Medium Control Flow
What is the final value of x?
int x = 0;
for(int i = 1; i
A 9
B 15
C 10
D 8
Correct Answer:  A. 9
EXPLANATION

continue skips even values. x accumulates: 1(i=1) + 3(i=3) + 5(i=5) = 9. Values i=2,4 are skipped.

Take Test
Q.756 Easy Control Flow
Analyze the code: What happens when condition in if statement is false?
if(0) { statements; } else { statements; }
A Program terminates
B Else block executes
C Infinite loop occurs
D Syntax error
Correct Answer:  B. Else block executes
EXPLANATION

When the if condition is false (0 is false in C), the else block executes. This is basic if-else control flow.

Take Test
Q.757 Medium Control Flow
What will be printed?
for(int i = 0; i < 3; i++) {
if(i == 1) goto skip;
printf("%d ", i);
}
skip: printf("End");
A 0 1 2 End
B 0 2 End
C 0 End
D 1 2 End
Correct Answer:  B. 0 2 End
EXPLANATION

When i=1, goto skip jumps to the skip label, skipping the printf. i continues to 2 in the loop. Output: 0 2 End

Take Test
Q.758 Medium Control Flow
What is the output?
int x = 5;
switch(x) {
case 5: printf("Five");
case 6: printf("Six");
default: printf("Default");
}
A Five
B FiveSixDefault
C FiveSix
D Six
Correct Answer:  B. FiveSixDefault
EXPLANATION

Without a break statement after case 5, control falls through to case 6 and default. This is called fall-through behavior in switch statements.

Take Test
Q.759 Medium Control Flow
In a nested loop, if we use 'goto' statement, where does the control transfer?
A To the label specified in goto statement
B To the outer loop only
C To the beginning of the loop
D To the next iteration
Correct Answer:  A. To the label specified in goto statement
EXPLANATION

'goto' transfers control to the label specified, which can be anywhere in the program. It can jump out of nested structures to the labeled location.

Take Test
Q.760 Medium Control Flow
What is the output of the following code?
for(int i = 1; i
A 11 21 31 32
B 11 12 31 32
C 11 31 32
D 11 12 21 31 32
Correct Answer:  C. 11 31 32
EXPLANATION

The break statement only exits the inner loop. When i=2 and j=1, inner loop breaks. i=3 executes normally. Output: 11 31 32

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