AllInfoHub Logo

AllInfoHub – MCQ Practice

Control Flow (if else switch) – Multiple Choice Questions (MCQs)

  1. 49. What is the output of the following code? `int x = 1, y = 2; if (x == 1 && y == 2) printf(\Both true\"); else printf(\""Not both true\"");`"""

    • A. Both true
    • B. Not both true
    • C. Error
    • D. 1 2
  2. 50. What is the output of the following code? `int x = 1, y = 3; if (x == 1 || y == 2) printf(\One true\"); else printf(\""None true\"");`"""

    • A. One true
    • B. None true
    • C. Error
    • D. 1 3
  3. 51. What is the output of the following code? `int z = 5; if (!(z == 5)) printf(\False\"); else printf(\""True\"");`"""

    • A. FALSE
    • B. TRUE
    • C. Error
    • D. 0
  4. 52. Can you have an 'if' statement inside another 'if' statement?

    • A. Yes
    • B. No
    • C. Only up to a certain depth
    • D. It depends on the compiler
  5. 53. Can you have a 'switch' statement inside an 'if' statement?

    • A. Yes
    • B. No
    • C. Only in certain cases
    • D. It depends on the compiler
  6. 54. Can you have an 'if' statement inside a 'switch' statement?

    • A. Yes
    • B. No
    • C. Only in the 'default' case
    • D. It depends on the compiler
  7. 55. What is the output of the following code? `int a = 5; if (a != 5) printf(\Not equal\"); else printf(\""Equal\"");`"""

    • A. Not equal
    • B. Equal
    • C. Error
    • D. 5
  8. 56. What is the output of the following code? `int b = 10; if (b >= 10) printf(\Greater or equal\"); else printf(\""Less\"");`"""

    • A. Greater or equal
    • B. Less
    • C. Error
    • D. 10
  9. 57. What is the output of the following code? `int c = 3; if (c <= 5) printf(\Less or equal\"); else printf(\""Greater\"");`"""

    • A. Less or equal
    • B. Greater
    • C. Error
    • D. 3
  10. 58. What is the output of the following code? `int d = -1; if (d > 0) printf(\Positive\"); else if (d < 0) printf(\""Negative\""); else printf(\""Zero\"");`"""

    • A. Positive
    • B. Negative
    • C. Zero
    • D. Error
  11. 59. What is the output of the following code? `int e = 0; if (e > 0) printf(\Positive\"); else if (e < 0) printf(\""Negative\""); else printf(\""Zero\"");`"""

    • A. Positive
    • B. Negative
    • C. Zero
    • D. Error
  12. 60. What is the output of the following code? `int f = 1; switch (f) { case 1: printf(\One\"); case 2: printf(\""Two\""); default: printf(\""Default\""); }`"""

    • A. One
    • B. Two
    • C. Default
    • D. OneTwoDefault