0% found this document useful (0 votes)
7 views

DPP 3

Uploaded by

shivamskashyap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

DPP 3

Uploaded by

shivamskashyap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1

C-Programming
Topic DPP 03

1. void main ()
{
int x = 5, y = 6, z = 2;
z = y / z ==3? y/z:x * y;
printf("%d",z);
}

2. main()
{
int ans =12, m = 10, k;
k = !((ans < 2) && (m > 2));
printf("\n%d",k);
}

3. void main()
{
int a = 500, b = 100, c = 30, d = 40, e = 19;
a += b -= c*= d/ =e% =5;
printf("%d %d %d %d %d",a, b, c, d, e);
}
4. void main()
{
int x,y,z;
x = 2 > 5 < = 0;
y = 2 > 3 <= 1;
z = 3 > 2 > 1 > 0;
printf("%d %d %d", x, y, z);

}
5. void main()
{
int x,y,z;
x = –1 <= 1 >= 2 <= 1;
y = 2 >= 2 <= 3 >= 4 <= 0;
z = 5 >= 8 <= 3 >= 0;
printf("%d %d %d",x,y,z);
}
2

6. void main()
{
int i=5;
printf("%d",i+++++i);
}

7. void main()
{
int a, b, c;
a = 3 > 2 && 5 <= 8;
b = 3 > (2 && 5) <= 8;
c = 3 < (2 && 5 >= 8);
printf("%d %d %d ",a,b,c);
}

8. void main()
{
int a,b,c;
a = 5 > 2!= 0||2! = 2;
b = 5 < (2!= 0)||2 = = 2!=1;
c = (5 = = 5)!= 0||2!= 5;
printf("%d %d %d",a,b,c);
}

9. void main()
{
int a=100, b=120;
j = a, b ? ( a , b ) ? a :b :b;
printf("%d %d", a , b);
}

10. void main()


{
int x=2, y=4;
y =y || --x && printf("Pankaj");
printf("%d %d", x, y);
}

11. void main()


{
int a;
a = printf("\nraman") + printf("\nramu") * printf("\nsinu") - printf("\nram");
printf("%d", a);
}
3

12. #include <stdio.h>


void main()
{
int i = -1;
int j = 8;
if (j > 5 && j < 10 )
if (j <= 7)
i = j * 8;
else
i = j + 8;
else
if (j > 3)
i = j / 8;
else
i = j - 8;
printf("%d", i);
}

13. #include<stdio.h>
void main()
{
int x, y, z = 0;
for (x = 6, y = 0; y <= 6; y++, x--)
z = (x == y) ? x: z;
printf("%d", z);
}

14. When following code is executed for input 10 a 20


void main()
{
int x, y;
scanf("%d %*c %d", &x, &y);
printf("%d %d", x, y);
}
(A) compilation error (B) garbage values.
(C) 12 12 (D) none of these.

15. #include<stdio.h>
void main()
{
int a;
a=20>100>100: !12!=3>50 ? 300 : 400 ;
printf("%d",a);
}
4

16. #include<stdio.h>
void main()
{
int a;
a= 2>5 ? 10 : 5<8!=1?20: !5 ? 30 :40 ;
printf("%d",a);
}

17. #include<stdio.h>
void main()
{
int a;
a= 2 > 5 ? 1!=2>5?10:20:5<8?2!=2>5?!5?30:!1!=1?40:50:60:70;
printf("%d",a);
}

18. #include<stdio.h>
void main()
{
int a;
a= 12 > 50 ? 1!=2>5?10:20<30||!2:5<8?2!=2>5?!5?30:!1!=1?40:50:60:70;
printf("%d",a);
}

19. #include<stdio.h>
void main()
{
int a;
a= 12 > 50 ? printf("GATE")||printf("%d",printf("pankaj")):printf("neeraj");
printf("%d",a);
}

20. #include<stdio.h>
void main()
{
int a;
a= 120 > 50 ? !printf("GATE") && printf("CSE")||printf("pankaj"):printf("neeraj");
printf("%d",a);
}

21. #include<stdio.h>
void main()
{
int a;
a= 120 > 50 ? !(printf("GATE") && printf("CSE"))||printf("pankaj"):printf("neeraj");
printf("%d",a);
}
5

22. Output of the following code is :


int main()
{
int a =100 + 010 + 001 ;
printf("%d",a);
return 0;
}
(A) 102 (B) 111
(C) 109 (D) Compilation Error

23. What is the output of the following code ?


#include <stdio.h>
int main()
{
int a ;
printf("%d",sizeof 10 ==sizeof 40);
return 0;
}
(A) 1 (B) 0
(C) 4 (D) Compilation Error

24. What is the output of the foollowing code?


#include<stdio.h>
int main()
{
int a;
a= 7>3 ? printf("Pankaj") && printf("Sir") || printf("Se") :printf("Bachao");
printf("%d",a);
return 0;
}
(A) PankajSirBachao (B) PankajSirSe
(C) PankajSirSe1 (D) PankajSir1
6

25. #include<stdio.h>
int main()
{
int a;
a=printf("")?printf("pankaj")||printf("SIR") && printf("C") || printf("Programming") : printf("DS")
?printf("Algorithm") :printf("Python Wale") ;
printf("%d",a);
}
The output is :
(A) pankajCDS (B) pankajCDSAlgorithm
(C) pankajAlgorithm (D) DSAlgorithm9

You might also like