Explore topic-wise MCQs in Bitwise Operators.

This section includes 38 Mcqs, each offering curated multiple-choice questions to sharpen your Bitwise Operators knowledge and support exam preparation. Choose a topic below to get started.

1.

What will be the output of the program? #include int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1<<2>

A. 32
B. 64
C. 128
Answer» B. 64
2.

What will be the output of the program? #include int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1>

A. 12400
B. 12480
C. 12500
D. 12556
Answer» C. 12500
3.

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); }

A. 3 2 3
B. 2 2 3
C. 3 2 2
D. 2 3 3
Answer» E.
4.

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); }

A. x is 97
B. x is 98
C. x is 99
D. Run time error
Answer» B. x is 98
5.

What will be the output of the following C code? #include int main() { unsigned int a = 10; a = ~a; printf("%d n", a); }

A. -9
B. -10
C. -11
D. 10
Answer» D. 10
6.

What will be the output of the following C code? #include int main() { int a = 2; if (a >> 1) printf("%d n", a); }

A. 1
B. 2
C. No Output
Answer» D.
7.

What will be the output of the following C code? #include int main() { int c = 2 ^ 3; printf("%d n", c); }

A. 1
B. 7
C. 9
Answer» B. 7
8.

What will be the output of the following C code? #include int main() { int y = 1; if (y & (y = 2)) printf("true %d n", y); else printf("false %d n", y); }

A. true 2
B. false 2
C. either true 2 or false 2
D. true 1
Answer» B. false 2
9.

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"); }

A. yes
B. no
C. run time error
D. undefined
Answer» B. no
10.

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); }

A. y is 1
B. 1
C. run time error
D. undefined
Answer» B. 1
11.

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"); }

A. Honesty is the best policy
B. Honesty
C. is the best policy
D. No output
Answer» D. No output
12.

Left shift (<<) and Right shift (>>) operators are equivalent to _____________ by 2. Choose the correct words...

A. Multiplication and Division
B. Division and Multiplication
C. Multiplication and Remainder
D. Remainder and Multiplication
Answer» B. Division and Multiplication
13.

Which Bitwise Operator can be used to check whether a number is EVEN or ODD quickly?

A. Bitwise AND (&)
B. Bitwise OR (|)
C. Bitwise XOR (^)
D. Bitwise NOT (~)
Answer» B. Bitwise OR (|)
14.

Which statement is suitable to check 3rd (count from 0) bit is high (set) or not?

A. (num & (1<<3))
B. (num & 0x08)
C. (num & 0x03)
D. Both (1) and (2)
Answer» E.
15.

Predict the output of following program. #include int main() { char flag=0x0f; flag &= ~0x02; printf("%d",flag); return 0; }

A. 13
B. d
C. 22
D. 10
Answer» B. d
16.

Consider the given statement: int x = 10 ^ 2 What will be the value of x?

A. 5
B. 6
C. 7
D. 8
Answer» E.
17.

Predict the output of following program. #include int main() { int x=10; x &= ~2; printf("x= %d",x); return 0; }

A. x= 10
B. x= 8
C. x= 12
D. x= 0
Answer» C. x= 12
18.

Predict the output of following program. #include int main() { char var=0x04; var = var | 0x04; printf("%d,",var); var |= 0x01; printf("%d",var); return 0; }

A. 8,9
B. 4,5
C. 8,8
D. 4,4
Answer» C. 8,8
19.

Predict the output of following program. #include #define MOBILE 0x01 #define LAPPY 0x02 int main() { unsigned char item=0x00; item |=MOBILE; item |=LAPPY; printf("I have purchased ...:"); if(item & MOBILE){ printf("Mobile, "); } if(item & LAPPY){ printf("Lappy"); } return 1; }

A. I have purchased ...:
B. I have purchased ...:Mobile, Lappy
C. I have purchased ...:Mobile,
D. I have purchased ...:Lappy
Answer» C. I have purchased ...:Mobile,
20.

Predict the output of following program. #include int main() { int a=10; int b=2; int c; c=(a & b); printf("c= %d",c); return 0; }

A. c= 12
B. c= 10
C. c= 2
D. c= 0
Answer» D. c= 0
21.

Which is not a bitwise operator?

A. &
B. |
C. <<
D. &&
Answer» E.
22.

What will be the output of the program? #include int main() { unsigned char i = 0x80; printf("%d n", i<<1>

A. 256
B. 100
C. 80
Answer» C. 80
23.

If an unsigned int is 2 bytes wide then, What will be the output of the program ? #include int main() { unsigned int a=0xffff; ~a; printf("%x n", a); return 0; }

A. ffff
B. 0000
C. 00ff
D. ddfd
Answer» B. 0000
24.

Assuming a integer 2-bytes, What will be the output of the program? #include int main() { printf("%x n", -1<<3>

A. ffff
B. fff8
C. 0
D. -1
Answer» C. 0
25.

In which numbering system can the binary number 1011011111000101 be easily converted to?

A. Decimal system
B. Hexadecimal system
C. Octal system
D. No need to convert
Answer» C. Octal system
26.

What will be the output of the program ? #include int main() { int i=32, j=0x20, k, l, m; k=i|j; l=i&j; m=k^l; printf("%d, %d, %d, %d, %d n", i, j, k, l, m); return 0; }

A. 0, 0, 0, 0, 0
B. 0, 32, 32, 32, 32
C. 32, 32, 32, 32, 0
D. 32, 32, 32, 32, 32
Answer» D. 32, 32, 32, 32, 32
27.

What will be the output of the program? #define P printf("%d n", -1^~0); #define M(P) int main() { P return 0; } M(P)

A. 1
B. -1
C. 2
Answer» A. 1
28.

If an unsigned int is 2 bytes wide then, What will be the output of the program ? #include int main() { unsigned int m = 32; printf("%x n", ~m); return 0; }

A. ffff
B. 0000
C. ffdf
D. ddfd
Answer» D. ddfd
29.

In which numbering system can the binary number 1011011111000101 be easily converted to?

A. Decimal system
B. Hexadecimal system
C. Octal system
D. No need to convert
Answer» C. Octal system
30.

Assunming, integer is 2 byte, What will be the output of the program? #include int main() { printf("%x n", -1>>1); return 0; }

A. ffff
B. 0fff
C. 0000
D. fff0
Answer» B. 0fff
31.

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); }

A. 4
B. 8
C. 1
D. Run time error
Answer» D. Run time error
32.

Which of the following statements are correct about the program? #include char *fun(unsigned int num, int base); int main() { char *s; s=fun(128, 2); s=fun(128, 16); printf("%s n",s); return 0; } char *fun(unsigned int num, int base) { static char buff[33]; char *ptr = &buff[sizeof(buff)-1]; *ptr = ' 0'; do { *--ptr = "0123456789abcdef"[num ?se]; num /=base; }while(num!=0); return ptr; }

A. It converts a number to a given base.
B. It converts a number to its equivalent binary.
C. It converts a number to its equivalent hexadecimal.
D. It converts a number to its equivalent octal.
Answer» B. It converts a number to its equivalent binary.
33.

Which of the following statements are correct about the program? #include int main() { unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; unsigned char n, i; scanf("%d", &n); for(i=0; i<=7; i++) { if(n & m[i]) printf("yes"); } return 0; }

A. It will put OFF all bits that are ON in the number n
B. It will test whether the individual bits of n are ON or OFF
C. It will put ON all bits that are OFF in the number n
D. It will report compilation errors in the if statement.
Answer» C. It will put ON all bits that are OFF in the number n
34.

Which of the following statements are correct about the program? #include int main() { unsigned int num; int c=0; scanf("%u", #); for(;num;num>>=1) { if(num & 1) c++; } printf("%d", c); return 0; }

A. It counts the number of bits that are ON (1) in the number num.
B. It counts the number of bits that are OFF (0) in the number num.
C. It sets all bits in the number num to 1
D. Error
Answer» B. It counts the number of bits that are OFF (0) in the number num.
35.

What will be the output of the program ? #include int main() { int i=4, j=8; printf("%d, %d, %d n", i|j&j|i, i|j&&j|i, i^j); return 0; }

A. 4, 8, 0
B. 1, 2, 1
C. 12, 1, 12
D. 0, 0, 0
Answer» D. 0, 0, 0
36.

In the statement expression1 >> expression2. if expression1 is a signed integer with its leftmost bit set to 1 then on right shifting it the result of the statement will vary from computer to computer

A. True
B. False
Answer» B. False
37.

Left shifting an unsigned int or char by 1 is always equivalent to multiplying it by 2.

A. True
B. False
Answer» B. False
38.

What will be the output of the program? #include int main() { printf("%d >> %d %d >> %d n", 4 >> 1, 8 >> 1); return 0; }

A. 4 1 8 1
B. 4 >> 1 8 >> 1
C. 2 >> 4 Garbage value >> Garbage value
D. 2 4
Answer» D. 2 4