Easy C Quiz - 3
17. What is the Output of the below C-Code.?
#includeANS : 540int main() { int i = 0X53F; printf ("%X", i + 1); }
18. What is the Output of the below C-Code.?
#includeANS : 0int main() { int x = 2, y = 0, z; z = y && (y | 10); printf("%d", z); }
19. What is the Output of the below C-Code.?
#includeANS : 1int main() { int x = 0, y; y = (x++, x); printf("%d", y); }
20. What is the Output of the below C-Code.?
#includeANS : 0 3 0.00000 2.00000int main() { int i = 2, j = 3, k, l; double a, b; k = i / j * j; l = j / i * j; a = i / j * i; b = j / i * i; printf("%d\n%d\n", k, l); printf("%f\n%f\n", a, b); }
21. What is the Output of the below C-Code.?
#includeANS : Compiler time errorint main() { printf("before continue "); continue; printf("after continue\n"); }
22. What is the Output of the below C-Code.?
#includeANS : n.o.aint main() { int a = 15; printf("%d %d %d", a, ++a, a++); return 0; }
23. What is the Output of the below C-Code.?
int main() { int x; for(x = 1; x <= 5; x++) { switch(x) { case 1: printf("www."); continue; case 2: case 3: case 4: continue; case 5: printf("cipheronics"); } printf(".com"); } return 0; }ANS : www.cipheronics.com
24. What is the Output of the below C-Code.?
#includeANS : 20int main() { int y = 2, z; z = (y + (y = 10)); printf("%d", z); }
25. What is the Output of the below C-Code.?
#includeANS : x=2, y=6int main() { int x = 2, y = 5; if (x == 2 && y++) { if (y==6 || ++x) { printf("x=%d, y=%d", x, y); } } }
26. What is the Output of the below C-Code.?
#includeANS : World a=0 b=0int main() { int a = 0X00000000; int b = 0X00000008; if ((a & b) || (a = b = 0)) { printf("Hello a=%d b=%d\n", a, b); } printf("World a=%d b=%d\n", a, b); }
27. What is the Output of the below C-Code.?
#includeANS : -121int main() { signed char c = 125; c = 125 + 10; printf("%d", c); return 0; }
28. What is the Output of the below C-Code.?
#includeANS : 24int main() { char c = 280; switch(c) { case 280: printf("280"); break; case 24: printf("24"); break; default: printf("No surprises"); break; } }
29. What is the Output of the below C-Code.?
#includeANS : Prints from 48 to 127int main() { unsigned char ch; for(ch='0';ch <= 127;ch++) printf("%d", ch); return 0; }
30. Which loop will run faster
// Code A for(int i=0; i<100 b="" code="" for="" i="" int="" j="" pre=""> ANS : Code B 31. What is the Output of the below C-Code.?#includeANS : -24 32. What is the Output of the below C-Code.?int main() { int a = -60, b = -34; unsigned int c = -24; printf("%d", c); return 0; } #includeANS : Hello 33. What is the Output of the below C-Code.?void main() { int i = 0; do { printf("Hello"); } while (i != 0); } #includeANS : Compiler error can't use continue 34. What is the Output of the below C-Code.?int main() { int x=5; switch(x*2) { case 15: printf("One"); break; case 10: continue; printf("Two"); default: printf("Three"); } return 0; } #includeANS : In while loop 2 35. What is the Output of the below C-Code.?int main() { int i = 0; do { i++; if (i == 2) continue; printf("In while loop "); } while (i < 2); printf("%d\n", i); } #includeANS : 8 36. What is the Output of the below C-Code.?int main() { int x, a = 7, b = 8, c = 2; x = a > b ? a > c ? a : c : b > c ? b : c; printf("%d", x); } #includeANS : 15 100>int main() { unsigned char c = 0xFF; int d; c >>= 4; d = c; printf("%d\n", d); }
Post a Comment