Control Flow (if else switch) – Multiple Choice Questions (MCQs)
-
-
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\"");`"""
-
51. What is the output of the following code? `int z = 5; if (!(z == 5)) printf(\False\"); else printf(\""True\"");`"""
-
52. Can you have an 'if' statement inside another 'if' statement?
-
53. Can you have a 'switch' statement inside an 'if' statement?
-
54. Can you have an 'if' statement inside a 'switch' statement?
-
55. What is the output of the following code? `int a = 5; if (a != 5) printf(\Not equal\"); else printf(\""Equal\"");`"""
-
56. What is the output of the following code? `int b = 10; if (b >= 10) printf(\Greater or equal\"); else printf(\""Less\"");`"""
-
57. What is the output of the following code? `int c = 3; if (c <= 5) printf(\Less or equal\"); else printf(\""Greater\"");`"""
-
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\"");`"""
-
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\"");`"""
-
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\""); }`"""