1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 2, y = 2;
float f = y + x /= x / y;
printf("%d %f\n", x, f);
return 0;
}
a) 2 4.000000
b) Compile time error
c) 2 3.500000
d) Undefined behaviour
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 1, y = 2;
if (x && y == 1)
printf("true\n");
else
printf("false\n");
}
a) true
b) false
c) compile time error
d) undefined behaviour
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 1, y = 2;
int z = x & y == 2;
printf("%d\n", z);
}
a) 0
b) 1
c) Compile time error
d) Undefined behaviour
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x /= y %= 2;
printf("%d\n", z);
}
a) 1
b) Compile time error
c) Floating point exception
d) Segmentation fault
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 3, y = 2;
int z = x << 1 > 5;
printf("%d\n", z);
}
a) 1
b) 0
c) 3
d) Compile time error
6. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 3;
const int *p = &x;
*p++;
printf("%d\n", *p);
}
a) Increment of read-only location compile error
b) 4
c) Some garbage value
d) Undefined behaviour
7. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 2, y = 2;
int z = x ^ y & 1;
printf("%d\n", z);
}
a) 1
b) 2
c) 0
d) 1 or 2
8. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 2, y = 0;
int z = x && y = 1;
printf("%d\n", z);
}
a) 0
b) 1
c) Compile time error
d) 2
9. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 0, y = 2;
if (!x && y)
printf("true\n");
else
printf("false\n");
}
a) True
b) False
c) Compile time error
d) Undefined behaviour
10. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 0, y = 2;
int z = ~x & y;
printf("%d\n", z);
}
a) -1
b) 2
c) 0
d) Compile time error