

MCQOPTIONS
Saved Bookmarks
This section includes 41 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
If an is 2 bytes wide then, What will be the output of the program ? |
A. | ffff |
B. | 0000 |
C. | 00ff |
D. | ddfd |
Answer» B. 0000 | |
2. |
Left shifting an or by 1 is always equivalent to multiplying it by 2. |
A. | True |
B. | False |
Answer» B. False | |
3. |
In the statement . if 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 | |
4. |
In which numbering system can the binary number be easily converted to? |
A. | Decimal system |
B. | Hexadecimal system |
C. | Octal system |
D. | No need to convert |
Answer» C. Octal system | |
5. |
Which of the following statements are correct about the program? #include int main() { unsigned int num; int i; scanf("%u", &num); for(i=0; i |
A. | It prints all even bits from num |
B. | It prints all odd bits from num |
C. | It prints binary equivalent num |
D. | Error |
Answer» D. Error | |
6. |
Which of the following statements are correct about the program?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ unsigned int m[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};_x000D_ unsigned char n, i;_x000D_ scanf("%d", &n);_x000D_ for(i=0; i |
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 | |
7. |
If an unsigned int is 2 bytes wide then, What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ unsigned int m = 32;_x000D_ printf("%x\n", ~m);_x000D_ return 0;_x000D_ } |
A. | ffff |
B. | 0000 |
C. | ffdf |
D. | ddfd |
Answer» D. ddfd | |
8. |
What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int i=4, j=8;_x000D_ printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j);_x000D_ return 0;_x000D_ } |
A. | 4, 8, 0 |
B. | 1, 2, 1 |
C. | 12, 1, 12 |
D. | 0, 0, 0 |
Answer» D. 0, 0, 0 | |
9. |
What will be the output of the program ?_x000D_ #include_x000D_ _x000D_ int main()_x000D_ {_x000D_ int i=32, j=0x20, k, l, m;_x000D_ k=i|j;_x000D_ l=i&j;_x000D_ m=k^l;_x000D_ printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);_x000D_ return 0;_x000D_ } |
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 | |
10. |
What will be the output of the program? #include int main() { printf("%d %d\n", 32-0); return 0; } |
A. | Garbage values |
B. | 64 320 3216 320 32 |
C. | All zeros |
D. | 8 00 032 00 16 |
Answer» C. All zeros | |
11. |
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. | 0 |
C. | -1 |
D. | 2 |
Answer» C. -1 | |
12. |
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 | |
13. |
What will be the output of the program? #include int main() { char c=48; int i, mask=01; for(i=1; i |
A. | 12400 |
B. | 12480 |
C. | 12500 |
D. | 12556 |
Answer» C. 12500 | |
14. |
Bitwise | can be used to set a bit in number. |
A. | Yes |
B. | No |
Answer» B. No | |
15. |
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 | |
16. |
Left shifting an unsigned int or char by 1 is always equivalent to multiplying it by 2. |
A. | 1 |
B. | |
Answer» B. | |
17. |
On left shifting, the bits from the left are rotated and brought to the right and accommodated where there is empty space on the right? |
A. | 1 |
B. | |
Answer» C. | |
18. |
Bitwise can be used to perform addition and subtraction. |
A. | Yes |
B. | No |
C. | Yes |
D. | No |
Answer» C. Yes | |
19. |
Bitwise | can be used to multiply a number by powers of 2. |
A. | Yes |
B. | No |
Answer» C. | |
20. |
Bitwise & and | are unary operators |
A. | 1 |
B. | |
Answer» C. | |
21. |
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 %base]; 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. | |
22. |
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. | 0 |
C. | 00ff |
D. | ddfd |
Answer» B. 0 | |
23. |
Bitwise | can be used to set multiple bits in number. |
A. | Yes |
B. | No |
Answer» B. No | |
24. |
Which of the following statements are correct about the program? #include int main() { unsigned int num; int c=0; scanf("%u", &num); 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. | |
25. |
Bitwise can be used to reverse a sign of a number. |
A. | Yes |
B. | No |
Answer» C. | |
26. |
Assuming a integer 2-bytes, What will be the output of the program? #include int main() { printf("%x\n", -1 |
A. | ffff |
B. | fff8 |
C. | 0  |
D. | -1 |
Answer» C. 0¬† | |
27. |
Bitwise & can be used to divide a number by powers of 2 |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» C. 1 | |
28. |
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 |
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 | |
29. |
What will be the output of the program? #include int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1 |
A. | 32 |
B. | 64 |
C. | 0 |
D. | 128 |
Answer» B. 64 | |
30. |
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. | 0 |
C. | ffdf |
D. | ddfd |
Answer» D. ddfd | |
31. |
Bitwise can be used to generate a random number. |
A. | Yes |
B. | No |
Answer» C. | |
32. |
Bitwise & can be used to check if more than one bit in a number is on. |
A. | 1 |
B. | |
Answer» B. | |
33. |
What will be the output of the program? #include int main() { unsigned char i = 0x80; printf("%d\n", i |
A. | 0 |
B. | 256 |
C. | 100 |
D. | 80 |
Answer» C. 100 | |
34. |
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 | |
35. |
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. | 1 |
B. | |
Answer» B. | |
36. |
Bitwise & can be used to check if a bit in number is set or not. |
A. | 1 |
B. | |
Answer» B. | |
37. |
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. | 0 |
D. | fff0 |
Answer» B. 0fff | |
38. |
Bitwise & can be used in conjunction with ~ operator to turn off 1 or more bits in a number. |
A. | Yes |
B. | No |
C. | Yes |
D. | No |
Answer» B. No | |
39. |
Which bitwise operator is suitable for checking whether a particular bit is on or off? |
A. | && operator |
B. | & operator |
C. | || operator |
D. | ! operator |
Answer» C. || operator | |
40. |
Left shifting a number by 1 is always equivalent to multiplying it by 2. |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» B. | |
41. |
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 | |