Operators Interview Questions

    Question 1Relational Operators

    Which of the following statements is true in C?

    Question 2Arithmetic Operators

    What is the output of the following C code?

    #include <stdio.h> int main() { int x = 15; int y = 4; printf("%d", x / y); return 0; }

    Question 3Modulus Operator

    What is the result of the expression 20 % 6?

    Question 4Logical AND Operator

    What is the output of the following C code?

    #include <stdio.h> int main() { int a = 10; int b = 5; printf("%d", (a > 5) && (b < 10)); return 0; }

    Question 5Pre-increment Operator

    What is the value of y after the following C code executes?

    #include <stdio.h> int main() { int x = 5; int y = ++x; return 0; }

    Question 6Post-decrement Operator

    What will be the final value of x after the following C code executes?

    #include <stdio.h> int main() { int x = 8; int y = x--; return 0; }

    Question 7Assignment Operators

    The expression x += 5; is equivalent to which of the following?

    Question 8Operator Precedence

    What is the output of the following C code?

    #include <stdio.h> int main() { printf("%d", 10 + 5 * 2); return 0; }

    Question 9Logical NOT Operator

    What is the value of the expression !0?

    Question 10C Ternary Operator

    What is the output of the following C code?

    #include <stdio.h> int main() { int age = 20; printf("%s", (age >= 18) ? "Adult" : "Minor"); return 0; }