Home Subjects C Programming Control Flow

C Programming
Control Flow

C language from basics to advanced placement prep

12 Q 10 Topics Take Mock Test
Advertisement
Difficulty: All Easy Medium Hard 11–12 of 12
Topics in C Programming
Q.11 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'.

Test
Q.12 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.

Test
IGET
IGET AI
Online · Exam prep assistant
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