0% found this document useful (0 votes)
108 views9 pages

DPP 2

Uploaded by

shivamskashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views9 pages

DPP 2

Uploaded by

shivamskashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

1

CS & IT
C Programming DPP 02

1. #include <stdio.h>
int main()
{
int a;
a = ('G'&'A')|'T'^('E' && printf("Pankaj")||printf("CS")); printf("%d", a);
return 0;
}
The output is: _____

2. Consider the following program:


#include<stdio.h>
void main()
{
int x=-2023;
printf("%d", ~(x = x + 5)) ;
}
The output is __________.

3. Consider the following program:


#include<stdio.h>
void main()
{
int x = –2024;
printf("%d", ~(x = x + 5)) ;
printf("%d", ~(x + 1));
}
The sum of the output values printed is __________.

4. #include <stdio.h>
int main()
{
int result = 2023 > 2025 ? 0 <= 1 ? printf("%d", printf("GATE") != 4) ? 2023 : 2022: 2021: 7 > 10 ||
printf("%d", 12 <= 11) ? printf("CS") != printf("IT")? 2025 : 2024 : 2030; printf("%d", result);
return 0;
}
The output is: _____
2

5. #include <stdio.h>
int main()
{
int a = 1, b = 5, c = 3, d;
d = a *= b++ + a << c--, printf("%d\t%d\t", b, c), ++a;
printf("%d\t%d", a, d);
return 0;
}
The sum of the printed values is ____.

6. #include <stdio.h>
int main()
{
char var = 0x05;
var = var^0x01;
printf("%d\t", var);
var = var <<1 + 1;
var – =10;
printf("%c\t", var + 64);
return 0;
}
The output is________.

7. #include<stdio.h>
void main()
{
int x = 4;
if(x++>3 && x++! = 4 && x++>5)
printf("%d", a);
else
printf("%d", a);
}
The output is :_______.
(A) 3 (B) 4
(C) 5 (D) None of the above

8. #include<stdio.h>
void main(){
int a, b, c;
a =– 1 >1;
b =– 1 >1L;
c =–1 >1U;
}
printf("%d %d %d", a, b, c);
(A) 111 (B) 001
(C) 110 (D) 100
3

9. #include<stdio.h>
void main()
{
int x = 1;
printf("%d",++(i++));
}

(A) 3 (B) 2
(C) 1 (D) Compilation Error

10. #include<stdio.h>
void main()
{
unsigned int x= 0xffff;
unsigned int y=~x;
printf("%d %d", x, y);
}
Assume int size as 2 bytes, the output is :
(A) –1 0 (B) –1 –1
(C) 65535 –65536 (D) –65535 0

11. #include<stdio.h>
void main()
{
int a = 10, b = 20, c, d = 1;
int e;
e = a > b? C = 10: d = 6;
printf("%d", e);
}
(A) 6 (B) 1
(C) 10 (D) Compilation Error

12. #include<stdio.h>
void main()
{
int a = 10, b = 20, c, d = 1;
int e;
e = a > b? c = 10: d, printf("pankaj");
printf("%d", e);
}
(A) pankaj1 (B) pankaj6
(C) pankaj10 (D) Compilation Error
4

13. #include<stdio.h>
void main()
{
if (2 > 3)
printf("2");
printf("3");
else
printf("4");
printf("5")
}
(A) 23 (B) 45
(C) 2345 (D) Compilation Error

14. #include<stdio.h>
void main()
{
if(printf("pankaj")-printf("sharma"))
printf("sir");
else
printf("Ji");
}
(A) pankajsharma
(B) pankajsharmasir
(C) pankajsharmasirJi
(D) pankajsharmaJi

15. #include <stdio.h>


int main(void)
{
int i = 2, j = 3, k = 4;
if (i < j? 1: 0)
printf(“GATE”);
else
printf(“PankajSharma”);
return 0;
}
The output of the program is ______.

16. #include <stdio.h>


void main( )
{
int a, b, c, d;
a = 2; b = –1; c = 3; d = –4;
if(a = b – c – d)
printf(“%d%d%d”, a++, b--, c++);
else
5

printf(“%d%d%d”, c--, ++ a, ++b);


}
The output is ______.
(A) 1 –2 4 (B) 3 1 0
(C) 2 1 –3 (D) 3 3 0

17. #include <stdio.h>


int main(void)
{
int a = 3 > 2 ? 0 ? 0 : 1 : 5;
if(a = = a – 1)
printf(“GATE 2025”);
else
printf(“Pankaj Sharma”);
return 0;
}
The output of the program is ______.

18. #include <stdio.h>


void main( )
{
int a;
a = printf(“GATE Sharma 2025”);
if(a%4 = = 0)
a = a + 5;
else
a = a – 5;
printf(“%d”, a++);
}
The value of a at the end of the program is ___.

19. #include <stdio.h>


void main( )
{
int i, j, k;
j = 4; k = 0;
i = j < k ? k : j --;
if(j < i)
j = j + k – 1;
if(j = = i)
j = j – i;
else
j = j + -- k,
printf(“%d”, j + k – i);
}
The output is ___.
6

20. Consider the following program:


#include<stdio.h>
int main()
{
int a = 19, b = 20;
if(a++ < b--) printf("%d",a+++--b);
else printf("%d", ++a+--b);
return 0;
}
The output is ____________.

21. #include<stdio.h>
void main()
{
int a = 0;
printf("%d", a);
if(a = 2)
{
printf("Hi");
printf("%d",a);
}
else
{
printf("Bye");
}
printf("%d", a);
}
The output string is:
(A) 0Hi22 (B) 0Hi20
(C) 0Bye0 (D) 0Hi00

22. #include<stdio.h>
void main()
{
int a = 0, b = 0;
a = (a = 4)||(b = 1);
if(a&&b) printf("CProgramming");
else printf("PankajSharma");
printf("%d" ,b);
}
The output is-
(A) CProgramming0
(B) CProgramming1
(C) PankajSharma0
(D) PankajSharma1
7

23. Consider the following program:


#include<stdio.h>
int main()
{
int i = 3;
for(;i++< = 9; ++i);
printf("%d",i);
return 0;
}
The output is _______.

24. Consider the following program:


#include<stdio.h>
int main()
{
int i=3;
for (;i++<=9;++i)
{
printf("best hai GATE Sharma");
if(i>8) break;
}
return 0;
}
The number of times printf() executed is ________

25. Consider the following program:


#include<stdio.h>
int main()
{
int a=0, b=1;
for(;b;printf("%d\t", a))
{
b = a++<=3;
}
return 0;
}
The output sequence is-
(A) 0 1 2 3 4 (B) 0 1 2 3
(C) 1 2 3 4 (D) 1 2 3 4 5
8

26. Consider the following program:


#include<stdio.h>
int main()
{
int i=0;
for(i=2; i<=n; i*=2)
printf("GATE SHARMA 2025");
return 0;
}
The number of times printf() executed is approximated as_________.
(A) 2n
(B) log2n
(C) log2log2n
(D) 2

27. Consider the following program:


#include <stdio.h>
int main()
{
int i;
for(i=printf("GATE");i<printf(“Sharma2025");)
{
if(i%2==0) i=i-1;
else i=i+2;
}
return 0;
}
The number of times “Sharma2025” is printed is____
(A) 4 (B) 5
(C) 6 (D) 7

28. Consider the following program:


#include <stdio.h>
int main()
{
int i, j, n;
for(i = 1;i<= n; i++)
for(j =1; j<=n; j++)
printf("GATE Sharma");
return 0;
}
How many times will the printf() statement be executed when n=32?
(1) 128 (2) 1024
(3) 512 (4) 256
9

29. Consider the following program:


#include <stdio.h>
int main()
{
int i, j, n, count=0;
for(i =1; i<=n;i++)
for(j =1; j<=i;j++)
count+=1;
printf("%d", count);
return 0;
}
When n = 31, the output is _______

30. Consider the following program:


#include <stdio.h>
int main()
{
int a,i;
a = 12.5/5+31.2/2*5-5;
for(i=a; i<90;i=i+3)
{
printf("%c\t", i+32);
}
return 0;
}
The output is_____.
(A) 107 110 113 116 119
(B) K L M N O
(C) k n q t w
(D) Garbage values

You might also like