C Programming Bitwise Operators Online Test
Finish Quiz
0 of 30 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
Information
C Programming Bitwise Operators Online Test. C Programming Question and Answers in English. C Programming Online Quiz. C Programming Bitwise Operators Online mock test paper is free for all students and Very Helpful for Exam Preparation. C Programming Bitwise Operators Online Quiz. C Programming Online Mock test for Bitwise Operators Topic. Here we are providing C Programming Bitwise Operators Online Test Series in English. Check C Programming Mock Test Series 2024-2024.
This paper has 30 questions.
Time allowed is 30 minutes.
The C Programming online Mock Test Exam is Very helpful for all students. Now Scroll down below n click on “Start Quiz” or “Start Test” and Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 30 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- Answered
- Review
-
Question 1 of 30
1. Question
In which numbering system can the binary number 1011011111000101 be easily converted to?
Correct
Hexadecimal system is better, because each 4-digit binary represents one Hexadecimal digit.
Incorrect
Hexadecimal system is better, because each 4-digit binary represents one Hexadecimal digit.
-
Question 2 of 30
2. Question
Which bitwise operator is suitable for turning off a particular bit in a number?
Correct
Incorrect
-
Question 3 of 30
3. Question
Which bitwise operator is suitable for turning on a particular bit in a number?
Correct
Incorrect
-
Question 4 of 30
4. Question
Which bitwise operator is suitable for checking whether a particular bit is on or off?
Correct
Incorrect
-
Question 5 of 30
5. Question
Assunming, integer is 2 byte, What will be the output of the program?
#include<stdio.h> int main() { printf("%x\n", -1>>1); return 0; }
Correct
Negative numbers are treated with 2’s complement method.
1’s complement: Inverting the bits ( all 1s to 0s and all 0s to 1s)
2’s complement: Adding 1 to the result of 1’s complement.Binary of 1(2byte) : 0000 0000 0000 0001 Representing -1: 1s complement of 1(2byte) : 1111 1111 1111 1110 Adding 1 to 1's comp. result : 1111 1111 1111 1111 Right shift 1bit(-1>>1): 1111 1111 1111 1111 (carry out 1) Hexadecimal : f f f f (Filled with 1s in the left side in the above step)
Note:
1. Fill with 1s in the left side for right shift for negative numbers.
2. Fill with 0s in the right side for left shift for negative numbers.
3. Fill with 0s in the left side for right shift for positive numbers.
4. Fill with 0s in the right side for left shift for positive numbers.Incorrect
Negative numbers are treated with 2’s complement method.
1’s complement: Inverting the bits ( all 1s to 0s and all 0s to 1s)
2’s complement: Adding 1 to the result of 1’s complement.Binary of 1(2byte) : 0000 0000 0000 0001 Representing -1: 1s complement of 1(2byte) : 1111 1111 1111 1110 Adding 1 to 1's comp. result : 1111 1111 1111 1111 Right shift 1bit(-1>>1): 1111 1111 1111 1111 (carry out 1) Hexadecimal : f f f f (Filled with 1s in the left side in the above step)
Note:
1. Fill with 1s in the left side for right shift for negative numbers.
2. Fill with 0s in the right side for left shift for negative numbers.
3. Fill with 0s in the left side for right shift for positive numbers.
4. Fill with 0s in the right side for left shift for positive numbers. -
Question 6 of 30
6. Question
If an unsigned int is 2 bytes wide then, What will be the output of the program ?
#include<stdio.h> int main() { unsigned int m = 32; printf("%x\n", ~m); return 0; }
Correct
Incorrect
-
Question 7 of 30
7. Question
Assuming a integer 2-bytes, What will be the output of the program?
#include<stdio.h> int main() { printf("%x\n", -1<<3); return 0; }
Correct
The system will treat negative numbers in 2’s complement method.
Example:
Assume the size of int is 2-bytes(16 bits). The integer value 1 is represented as given below:
Binary of 1: 00000000 00000001 (this is for positive value of 1)
1’s complement of binary 1: 11111111 11111110
2’s complement of binary 1: 11111111 11111111Thy system will store ‘11111111 11111111’ in memory to represent ‘-1’.
If we do left shift (3 bits) on 11111111 11111111 it will become as given below:
11111111 11111111 —(left shift 3 times)—> 11111111 11111000.
So, 11111111 11111000 —(binary to hex)—> FF F8. (Required Answer)
Note:
How is the negative number obtained from 2’s complement value?
As stated above, -1 is represented as ‘11111111 11111111’ in memory.
So, the system will take 2’s complement of ‘11111111 11111111’ to the get the original negative value back.
Example:
Bit Representation of -1: 11111111 11111111
Since the left most bit is 1, it is a negative number. Then the value is
1’s complement: 00000000 00000000
2’s complement: 00000000 00000001 (Add 1 to the above result)Therefore, ‘00000000 00000001’ = 1 and the sign is negative.
Hence the value is -1.
Incorrect
-
Question 8 of 30
8. Question
If an unsigned int is 2 bytes wide then, What will be the output of the program ?
#include<stdio.h> int main() { unsigned int a=0xffff; ~a; printf("%x\n", a); return 0; }
Correct
Incorrect
-
Question 9 of 30
9. Question
What will be the output of the program?
#include<stdio.h> int main() { unsigned char i = 0x80; printf("%d\n", i<<1); return 0; }
Correct
Incorrect
-
Question 10 of 30
10. Question
What will be the output of the program?
#include<stdio.h> int main() { printf("%d >> %d %d >> %d\n", 4 >> 1, 8 >> 1); return 0; }
Correct
Incorrect
-
Question 11 of 30
11. Question
What will be the output of the program?
#include<stdio.h> int main() { char c=48; int i, mask=01; for(i=1; i<=5; i++) { printf("%c", c|mask); mask = mask<<1; } return 0; }
Correct
Incorrect
-
Question 12 of 30
12. Question
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)
Correct
Incorrect
-
Question 13 of 30
13. Question
What will be the output of the program ?
#include<stdio.h> 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; }
Correct
Incorrect
-
Question 14 of 30
14. Question
What will be the output of the program?
#include<stdio.h> int main() { printf("%d %d\n", 32<<1, 32<<0); printf("%d %d\n", 32<<-1, 32<<-0); printf("%d %d\n", 32>>1, 32>>0); printf("%d %d\n", 32>>-1, 32>>-0); return 0; }
Correct
Incorrect
-
Question 15 of 30
15. Question
What will be the output of the program?
#include<stdio.h> int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1<<2)); printf("%d\n", res); return 0; }
Correct
Incorrect
-
Question 16 of 30
16. Question
What will be the output of the program ?
#include<stdio.h> int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j); return 0; }
Correct
Incorrect
-
Question 17 of 30
17. Question
Which of the following statements are correct about the program?
#include<stdio.h> int main() { unsigned int num; int i; scanf("%u", &num); for(i=0; i<16; i++) { printf("%d", (num<<i & 1<<15)?1:0); } return 0; }
Correct
If we give input 4, it will print 00000000 00000100 ;
If we give input 3, it will print 00000000 00000011 ;
If we give input 511, it will print 00000001 11111111 ;
Incorrect
If we give input 4, it will print 00000000 00000100 ;
If we give input 3, it will print 00000000 00000011 ;
If we give input 511, it will print 00000001 11111111 ;
-
Question 18 of 30
18. Question
Which of the following statements are correct about the program?
#include<stdio.h> int main() { unsigned int num; int c=0; scanf("%u", &num); for(;num;num>>=1) { if(num & 1) c++; } printf("%d", c); return 0; }
Correct
If we give input 4, it will print 1.
Binary-4 == 00000000 00000100 ; Total number of bits = 1.If we give input 3, it will print 2.
Binary-3 == 00000000 00000011 ; Total number of bits = 2.If we give input 511, it will print 9.
Binary-511 == 00000001 11111111 ; Total number of bits = 9.Incorrect
If we give input 4, it will print 1.
Binary-4 == 00000000 00000100 ; Total number of bits = 1.If we give input 3, it will print 2.
Binary-3 == 00000000 00000011 ; Total number of bits = 2.If we give input 511, it will print 9.
Binary-511 == 00000001 11111111 ; Total number of bits = 9. -
Question 19 of 30
19. Question
Which of the following statements are correct about the program?
#include<stdio.h> 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; }
Correct
Incorrect
-
Question 20 of 30
20. Question
Which of the following statements are correct about the program?
#include<stdio.h> 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; }
Correct
Incorrect
-
Question 21 of 30
21. Question
Left shifting a number by 1 is always equivalent to multiplying it by 2.
Correct
0001 => 1
0010 => 2
0100 => 4
1000 => 8Incorrect
0001 => 1
0010 => 2
0100 => 4
1000 => 8 -
Question 22 of 30
22. Question
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
Correct
Incorrect
-
Question 23 of 30
23. Question
Bitwise & and | are unary operators
Correct
Bitwise & and | are not unary operators only bitwise ! is unary operator.Incorrect
Bitwise & and | are not unary operators only bitwise ! is unary operator. -
Question 24 of 30
24. Question
Bitwise & can be used to check if more than one bit in a number is on.
Correct
Incorrect
-
Question 25 of 30
25. Question
Bitwise & can be used to check if a bit in number is set or not.
Correct
Incorrect
-
Question 26 of 30
26. Question
Bitwise & can be used to divide a number by powers of 2
Correct
Incorrect
-
Question 27 of 30
27. Question
Left shifting an unsigned int or char by 1 is always equivalent to multiplying it by 2.
Correct
Incorrect
-
Question 28 of 30
28. Question
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?
Correct
Incorrect
-
Question 29 of 30
29. Question
Bitwise & can be used in conjunction with ~ operator to turn off 1 or more bits in a number.
Correct
Incorrect
-
Question 30 of 30
30. Question
Bitwise can be used to reverse a sign of a number.
Correct
Incorrect