This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Bitwise Operators – 2”.
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>
void main()
{
int a = 5, b = -7, c = 0, d;
d = ++a && ++b || ++c;
printf("\n%d%d%d%d", a, b, c, d);
}
a) 6 -6 0 0
b) 6 -5 0 1
c) -6 -6 0 1
d) 6 -6 0 1
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int a = -5;
int k = (a++, ++a);
printf("%d\n", k);
}
a) -3
b) -5
c) 4
d) Undefined
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 2;
x = x << 1;
printf("%d\n", x);
}
a) 4
b) 1
c) Depends on the compiler
d) Depends on the endianness of the machine
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = -2;
x = x >> 1;
printf("%d\n", x);
}
a) 1
b) -1
c) 2 31 – 1 considering int to be 4 bytes
d) Either -1 or 1
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
if (~0 == 1)
printf("yes\n");
else
printf("no\n");
}
a) yes
b) no
c) compile time error
d) undefined
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
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
View Answer
Explanation: None.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Watch Advanced C Programming Videos
- Check Computer Science Books
- Practice Computer Science MCQs
- Practice BCA MCQs
- Apply for C Internship