This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Bitwise Operators – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int c = 2 ^ 3;
printf("%d\n", c);
}
a) 1
b) 8
c) 9
d) 0
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
unsigned int a = 10;
a = ~a;
printf("%d\n", a);
}
a) -9
b) -10
c) -11
d) 10
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 2;
if (a >> 1)
printf("%d\n", a);
}
a) 0
b) 1
c) 2
d) No Output
View Answer
Explanation: None.
5. Comment on the output of the following C code.
#include <stdio.h>
int main()
{
int i, n, a = 4;
scanf("%d", &n);
for (i = 0; i < n; i++)
a = a * 2;
}
a) Logical Shift left
b) Logical Shift Right
c) Arithmetic Shift right
d) Bitwise exclusive OR
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Check C Books
- Practice BCA MCQs
- Practice Computer Science MCQs
- Apply for Computer Science Internship