Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views5 pages

Bitwise Operator Questions

The document contains multiple C code snippets along with questions asking for their outputs or comments on the code behavior. Each code snippet tests various aspects of C programming, including logical operations, bitwise operations, and the behavior of increment operators. The document is structured as a quiz or exercise for understanding C programming concepts.

Uploaded by

ponselvam132
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)
17 views5 pages

Bitwise Operator Questions

The document contains multiple C code snippets along with questions asking for their outputs or comments on the code behavior. Each code snippet tests various aspects of C programming, including logical operations, bitwise operations, and the behavior of increment operators. The document is structured as a quiz or exercise for understanding C programming concepts.

Uploaded by

ponselvam132
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/ 5

1) What will be the output of the following C code?

1. #include <stdio.h>
2. void main()
3. {
4. int a = 5, b = -7, c = 0, d;
5. d = ++a && ++b || ++c;
6. printf("\n%d %d %d %d", a, b, c, d);
7. }
2) What will be the output of the following C code?
1. #include <stdio.h>
2. void main()
3. {
4. int a = -5;
5. int k = (a++, ++a);
6. printf("%d\n", k);
7. }
3) What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. if (~0 == 1)
5. printf("yes\n");
6. else
7. printf("no\n");
8. }
4) What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int y = 0;
5. if (1 |(y = 1))
6. printf("y is %d\n", y);
7. else
8. printf("%d\n", y);
9.
10. }
5) What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. if (7 & 8)
5. printf("Honesty");
6. if ((~7 & 0x000f) == 8)
7. printf("is the best policy\n");
8. }
6) What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int y = 1;
5. if (y & (y = 2))
6. printf("true %d\n", y);
7. else
8. printf("false %d\n", y);
9.
10. }
7) Comment on the output of the following C code.
1. #include <stdio.h>
2. int main()
3. {
4. int i, n, a = 4;
5. scanf("%d", &n);
6. for (i = 0; i < n; i++)
7. a = a * 2;
8. }
a) Logical Shift left
b) Logical Shift Right
c) Arithmetic Shift right
d) Bitwise exclusive OR

8) What will be the output of the following C code?


1. #include <stdio.h>
2. int main()
3. {
4. unsigned int a = 10;
5. a = ~a;
6. printf("%d\n", a);
7. }
9) What will be the output of the following C code?
1. #include <stdio.h>
2. int main()
3. {
4. int a = 2;
5. if (a >> 1)
6. printf("%d\n", a);
7. }
10) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 10;
5. int y = sizeof(x++);
6. printf("%d %d", x, y);
7. }
11) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 0;
5. if (x++ && x++)
6. x++;
7. printf("%d", x);
8. }
12) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 3;
5. if (x == 3 || x++ == 4)
6. printf("%d", x);
7. }
13) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 3;
5. int y = 3;
6. int z = (x++, y++, x + y);
7. printf("%d %d %d", x, y, z);
8. }
14) Predict the output of following program.
1. #include <stdio.h>
2. int main()
3. {
4. int a=10;
5. int b=2;
6. int c;
7. c=(a & b);
8. printf("c= %d",c);
9. return 0;
10.}
15) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 5;
5. printf(“%d”, sizeof(x=x+10));
6. printf(“ %d”, x);
7. }
16) What is the output?
1. #include <stdio.h>
2. int main()
3. {
4. int x = 1;
5. if(x == 1 && x++ == 1)
6. printf(“ %d”, x);
7. }

You might also like