Control Flow Statements - DPP 01
Control Flow Statements - DPP 01
if(a++<b--) printf("%d",a+++--b); }
else printf("%d", ++a+--b); The output string is:
return 0; (a) 0Hi22 (b) 0Hi20
(c) 0Bye0 (d) 0Hi00
}
The output is ____________. [MCQ]
8. #include<stdio.h>
[MCQ] void main()
7. #include<stdio.h> {
void main() int a=0, b=0;
{ a=(a=4)||(b=1);
int a=0; if(a&&b) printf("CProgramming");
printf("%d", a); else printf("PankajSharma");
if(a=2){ printf(“%d”,b);
printf("Hi"); }
printf("%d",a); The output is-
}else{ (a) CProgramming0
printf("Bye"); (b) CProgramming1
} (c) PankajSharma0
printf("%d", a); (d) PankajSharma1
3
Answer Key
1. (GATE) 6. (38)
2. (b) 7. (a)
3. (b) 8. (c)
4. (22)
5. (–4)
4
2. (c) a 16 21 22
a=–1–3+4 Hence the final value of a is 22.
a=0
a 2 0 5. (–4)
Assignment operator assigns and returns the value i j k
4 4 0 –1
b + + b: − 1 0 ,
3 2 1
a ++a: 0 1 , 3<4
j=3+0–1=2
c c−−: 3 2
2!=4
j=j–1
Post decrement (It will print 3, then update to 2) =2–1
Output: 3 1 0 j=1
printed value = j + k – i
3. (b) =1–1–4
= –4
6. (38)
If(19<20)→ Condition is true. After the condition is
evaluated, a is incremented to 20 and b is decremented
to 19.
a=1 Now, printf("%d",a+++--b); is evaluated. b is
Assignment operator assigns the value and returns it decremented to 18. So, (20+18) i.e. 38 is printed. After
that, a is incremented to 21.
if (a = a – 1) Hence, output is 38.
1 4 2 43
0
7. (a)
Condition: false
void main()
Output: GATE WALLAH {
int a=0;
4. (GATE Wallah 202321)
printf("%d", a); // 0 is printed
GATE Wallah 2023 if(a=2){//Assignment operator assigns and returns the
assigned value; So 2 is assigned to a and 2 is returned.
a = 16 Any non-zero value is considered true.
printf("Hi");//”Hi” is printed
5