C/C MCQ Quiz Hub

C Multiple Choice Questions C Operators

Choose a topic to test your knowledge and improve your C/C skills

What is the output of this C code? int main() { int i = -5; int k = i %4; printf("%d ", k); }





✅ Correct Answer: 2

What is the output of this C code? int main() { int i = 5; int l = i / -4; int k = i % -4; printf("%d %d ", l, k); return 0; }





✅ Correct Answer: 2

What is the output of this C code? int main() { int i = 7; i = i / 4; printf("%d ", i); return 0; }





✅ Correct Answer: 2

What is the value of x in this C code? void main() { int x = 4 *5 / 2 + 9; }





✅ Correct Answer: 3

What is the output of this C code? void main() { int x = 4.3 % 2; printf("Value of x is %d", x); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int y = 3; int x = 7 % 4 * 3 / 2; printf("Value of x is %d", x); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int a = 5; int b = ++a + a++ + --a; printf("Value of b is %d", b); }





✅ Correct Answer: 4

The precedence of arithmetic operators is (from highest to lowest)?





✅ Correct Answer: 1

Which of the following is not an arithmetic operation?





✅ Correct Answer: 4

Which of the following data type will throw an error on modulus operation(%)?





✅ Correct Answer: 3

What is the output of this C code? int main() { int a = 20; double b = 15.6; int c; c = a + b; printf("%d", c); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int a = 20, b = 15, c = 5; int d; d = a == (b + c); printf("%d", d); } A. 1





✅ Correct Answer: 1

What is the output of this C code? void main() { int x = 0; if (x = 0) printf("Its zero "); else printf("Its not zero "); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int k = 8; int x = 0 == 1 && k++; printf("%d%d ", x, k); }





✅ Correct Answer: 2

What is the output of this C code? void main() { char a = 'a'; int x = (a % 10)++; printf("%d ", x); }





✅ Correct Answer: 3

What is the output of this C code? void main() { 1 < 2 ? return 1: return 2; }





✅ Correct Answer: 4

What is the output of this C code? void main() { unsigned int x = -5; printf("%d", x); }





✅ Correct Answer: 3

What is the output of this C code? void main() { unsigned int x = -5; printf("%d", x); }





✅ Correct Answer: 3

What is the output of this C code? int main() { int x = 2, y = 1; x *= x + y; printf("%d ", x); return 0; }





✅ Correct Answer: 4

What is the output of this C code? int main() { int x = 2, y = 2; x /= x / y; printf("%d ", x); return 0; }





✅ Correct Answer: 1

What is the type of the below assignment expression if x is of type float, y is of type int? y = x + y;





✅ Correct Answer: 1

What is the value of the below assignment expression (x = foo())!= 1 considering foo() returns 2





✅ Correct Answer: 1

Operation "a = a * b + a can also be written as:





✅ Correct Answer: 4

for c = 2, value of c after c <<= 1;





✅ Correct Answer: 4

What is the output of this C code? int main() { int a = 1, b = 2; a += b -= a; printf("%d %d", a, b); }





✅ Correct Answer: 3

What is the output of this C code? int main() { int a = 4, n, i, result = 0; scanf("%d", n); for (i = 0;i < n; i++) result += a; }





✅ Correct Answer: 3

Which of the following is an invalid assignment operator?





✅ Correct Answer: 4

What is the output of this C code? int main() { int c = 2 ^ 3; printf("%d ", c); }





✅ Correct Answer: 1

What is the output of this C code? int main() { unsigned int a = 10; a = ~a; printf("%d ", a); }





✅ Correct Answer: 3

What is the output of this C code? int main() { if (7 & 8) printf("Honesty"); if ((~7 & 0x000f) == 8) printf("is the best policy "); }





✅ Correct Answer: 3

What is the output of this C code? int main() { int a = 2; if (a >> 1) printf("%d ", a); }





✅ Correct Answer: 3

What is the output of this C code? int main() { int a = 2; if (a >> 1) printf("%d ", a); }





✅ Correct Answer: 3

Comment on the output of this C code? int main() { int i, n, a = 4; scanf("%d", &n); for (i = 0; i < n; i++) a = a * 2; }





✅ Correct Answer: 2

What is the output of this C code? void main() { int x = 97; int y = sizeof(x++); printf("x is %d", x); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int x = 4, y, z; y = --x; z = x--; printf("%d%d%d", x, y, z); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int x = 4; int *p = &x; int *k = p++; int r = p - k; printf("%d", r); }





✅ Correct Answer: 3

What is the output of this C code? void main() { int a = 5, b = -7, c = 0, d; d = ++a && ++b || ++c; printf(" %d%d%d%d", a, b, c, d); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int a = -5; int k = (a++, ++a); printf("%d ", k); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int x = 2; x = x << 1; printf("%d ", x);





✅ Correct Answer: 1

What is the output of this C code? int main() { int x = -2; x = x >> 1; printf("%d ", x); }





✅ Correct Answer: 2

What is the output of this C code? int main() { if (~0 == 1) printf("yes "); else printf("no "); }





✅ Correct Answer: 2

What is the output of this C code? int main() { int x = -2; if (!0 == 1) printf("yes "); else printf("no "); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int y = 0; if (1 |(y = 1)) printf("y is %d ", y); else printf("%d ", y); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int y = 1; if (y & (y = 2)) printf("true %d "); else printf("false %d "); }





✅ Correct Answer: 3

What is the difference between the following 2 codes? //Program 1 int main() { int d, a = 1, b = 2; d = a++ + ++b; printf("%d %d %d", d, a, b); } //Program 2 int main() { int d, a = 1, b = 2; d = a++ + ++b; printf("%d %d %d", d, a, b); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int a = 1, b = 1, c; c = a++ + b; printf("%d, %d", a, b); }





✅ Correct Answer: 2

What is the output of this C code? int main() { int a = 1, b = 1, d = 1; printf("%d, %d, %d", ++a + ++a+a++, a++ + ++b, ++d + d++ + a++); }





✅ Correct Answer: 1

For which of the following, "PI++; code will fail?





✅ Correct Answer: 1

What is the output of this C code? int main() { int a = 10, b = 10; if (a = 5) b--; printf("%d, %d", a, b--); }





✅ Correct Answer: 3

What is the output of this C code? int main() { int i = 0; int j = i++ + i; printf("%d ", j); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int i = 2; int j = ++i + i; printf("%d ", j); }





✅ Correct Answer: 1

Comment on the output of this C code? int main() { int i = 2; int i = i++ + i; printf("%d ", i); }





✅ Correct Answer: 1

What is the output of this C code? int main() { int i = 0; int x = i++, y = ++i; printf("%d % d ", x, y); return 0; }





✅ Correct Answer: 1

What is the output of this C code? int main() { int i = 10; int *p = &i; printf("%d ", *p++); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int x = 97; int y = sizeof(x++); printf("X is %d", x); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int x = 4, y, z; y = --x; z = x--; printf("%d%d%d", x, y, z); }





✅ Correct Answer: 2

What is the output of this C code? void main() { int x = 4; int *p = &x; int *k = p++; int r = p - k; printf("%d", r); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int a = 5, b = -7, c = 0, d; d = ++a && ++b || ++c; printf(" %d%d%d%d", a, b, c, d); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int a = -5; int k = (a++, ++a); printf("%d ", k); } A. -4B. -5C. 4D. -3





✅ Correct Answer: 4

What is the output of this C code? void main() { int x = 1, y = 0, z = 5; int a = x && y || z++; printf("%d", z); }





✅ Correct Answer: 1

What is the output of this C code? void main() { int x = 1, y = 0, z = 5; int a = x && y && z++; printf("%d", z); }





✅ Correct Answer: 2

What is the output of this C code? int main() { int x = 1, y = 0, z = 3; x > y ? printf("%d", z) : return z; }





✅ Correct Answer: 3

What is the output of this C code? void main() { int x = 1, z = 3; int y = x << 3; printf(" %d ", y); }





✅ Correct Answer: 4

What is the output of this C code? void main() { int x = 0, y = 2, z = 3; int a = x & y | z; printf("%d", a); }





✅ Correct Answer: 1

What is the final value of j in the below code? int main() { int i = 0, j = 0; if (i && (j = i + 10)) //do something ; }





✅ Correct Answer: 1

What is the output of this C code? int main() { int i = 1; if (i++ && (i == 1)) printf("Yes "); else printf("No "); }





✅ Correct Answer: 1

Are logical operators sequence points?





✅ Correct Answer: 1

Does logical operators in C language are evaluated with short circuit?





✅ Correct Answer: 1

Result of a logical or relational expression in C is?





✅ Correct Answer: 2

What will be the value of d in the following program? int main() { int a = 10, b = 5, c = 5; int d; d = b + c == a; printf("%d", d); } A





✅ Correct Answer: 2

What is the output of this C code? int main() { int a = 10, b = 5, c = 3; b != !a; c = !!a; printf("%d %d", b, c); }





✅ Correct Answer: 1

Which among the following is NOT a logical or relational operator? A. !=B. ==C. ||D. = Which among the following is NOT a logical or relational operator?





✅ Correct Answer: 4

What is the output of this C code? int main() { int a = 10; if (a == a--) printf("TRUE 1 "); a = 10; if (a == --a) printf("TRUE 2 "); }





✅ Correct Answer: 3

Relational operators cannot be used on:





✅ Correct Answer: 1