Professional Documents
Culture Documents
5control Flow Statements - DPP 03 (Of Lec 04)
5control Flow Statements - DPP 03 (Of Lec 04)
5control Flow Statements - DPP 03 (Of Lec 04)
[NAT] }
1. #include <stdio.h>
printf("%d\t%d", a, b);
int main()
return 0;
{
}
int a=7, b=8;
The output is-
while(++b & a-- ) (a) 4 8 (b) 3 9
(c) 3 10 (d) 4 6
{
printf("HI!"); [MCQ]
3. int main()
}
{
return 0;
int a=1, b=2;
}
do
The number of times the printf() executed is _______.
{
[MCQ] while(b++)
2. #include <stdio.h>
{
int main()
b=b-a;
{
a=a+b;
int a=5, b=10;
}
while(++b & a-- )
}
{
while(a++<2);
switch (b)
printf("%d\t%d", a, b);
{
return 0;
case 0: b=b-1;
}
break;
The output is-
case 1: b=b-2;
(a) 3 0 (b) 4 2
break; (c) 3 2 (d) 4 1
default: b=b-3;
break;
}
2
[MCQ] printf("%d",i);
4. #include <stdio.h>
}
int main()
while(i++);
{ return 0;
int a,b; }
a=printf("GATE")>printf("Wallah")?printf("2023"):p The sum of all printed values of i is ____?
rintf("Hi!!");
b=a-1; [MCQ]
while(a>b) 6. #include <stdio.h>
int main()
{
{
switch(b)
int a, b;
{
while(a!=b)
case 1: b=--a;
{
case 2:b=a--;
a=a/2;
default:b=--a;
b=b*2;
}
if(b>a) break;
}
}
printf("%d%d", a, b);
return 0;
return 0;
}
}
If a = 2m and b = 2n where m-n is even and positive,
The output string is- the number of times the loop runs is-
[NAT]
[NAT]
5. #include <stdio.h>
7. #include <stdio.h>
int main()
int main()
{
{
int i=16;
int x=5, y=10;
do
if(printf("GATE")-3){
{
while(x--) y=y+x;}
i=i-2;
else y=y-x;
3
return 0; while(x-=y++<10){
} printf("GATE WALLAH\n");
The value of y at the end of the program is ______. }
return 0;
[NAT]
}
8. #include <stdio.h>
The number of times “GATE WALLAH” printed is
int main()
__________.
{
int x=5, y=5;
Answer Key
1. (7) 6. (a)
2. (b) 7. (20)
3. (d) 8. (4)
4. (a)
5. (105)
4
10 & 6 → True. 1010 a = print f (“GATE”) > printf (“Wallah” )?printf(“2023”): printf(“Hi!!”);
↓
0110 4 > 6 False
↓
printf → executed ; 0010
do 5. (105)
{ Do
While (b++) {
{
// values assigned are 2, 2, 0 i = i – 2;
b = b – a = 3 – 1 = 2 // 3 – 3 = 0 printf(“%d”,j); //14 13 ….. 0
a = a + b = 1 + 2 = 3 // 3 + 0 = 3
} }
} while (i ++);
5
while (a ! = b) 8. (4)
{ x-=y++<10 will make the condition true for x = 4, 3,
2, 1 and y=5, 6, 7, 8.
1024 ! = 64 True
Hence, printf() will be executed 4 times.
256 ! = 256 False
a = a/2; //a = 512, 256