#include int main() { int c = 2 ^ 3; printf("%d\n", c); }
1
8
9
0
What will be the output of the following C code?
#include int main() { unsigned int a = 10; a = ~a; printf("%d\n", a); }
-9
-10
-11
10
What will be the output of the following C code?
#include int main() { if (7 & 8) printf("Honesty"); if ((~7 & 0x000f) == 8) printf("is the best policy\n"); }
Honesty is the best policy
Honesty
is the best policy
No output
What will be the output of the following C code? #include int main() { int a = 2; if (a >> 1) printf("%d\n", a); }
0
1
2
No Output
Comment on the output of the following C code.
#include int main() { int i, n, a = 4; scanf("%d", &n); for (i = 0; i < n; i++) a = a * 2; }
Logical Shift left
No output
Arithmetic Shift right
Bitwise exclusive OR
What will be the output of the following C code?
#include void main() { int x = 97; int y = sizeof(x++); printf("x is %d", x); }
x is 97
x is 98
x is 99
Run time error
What will be the output of the following C code?
#include void main() { int x = 4, y, z; y = --x; z = x--; printf("%d%d%d", x, y, z); }
3 2 3
2 2 3
3 2 2
2 3 3
What will be the output of the following C code?
#include void main() { int x = 4; int *p = &x; int *k = p++; int r = p - k; printf("%d", r); }
4
8
1
Run time error
What will be the output of the following C code? #include void main() { int a = 5, b = -7, c = 0, d; d = ++a && ++b || ++c; printf("\n%d%d%d%d", a, b, c, d); }
6 -6 0 0
6 -5 0 1
-6 -6 0 1
6 -6 0 1
What will be the output of the following C code?
#include void main() { int a = -5; int k = (a++, ++a); printf("%d\n", k); }
-3
-5
4
Undefined
What will be the output of the following C code?
#include int main() { int x = 2; x = x << 1; printf("%d\n", x); }
4
1
Depends on the compiler
Depends on the endianness of the machine
What will be the output of the following C code? #include int main() { int x = -2; x = x >> 1; printf("%d\n", x); }
1
-1
0
Either -1 or 1
What will be the output of the following C code?
#include int main() { if (~0 == 1) printf("yes\n"); else printf("no\n"); }
yes
no
compile time error
undefined
What will be the output of the following C code?
#include int main() { int x = -2; if (!0 == 1) printf("yes\n"); else printf("no\n"); }
yes
no
run time error
undefined
What will be the output of the following C code?
#include int main() { int y = 0; if (1 |(y = 1)) printf("y is %d\n", y); else printf("%d\n", y);