Control Flow (if else switch) – Multiple Choice Questions (MCQs)
-
-
26. Can you have multiple 'else if' statements after a single 'if' statement?
-
27. What is the purpose of the '!' operator when used in an 'if' condition?
-
28. What will be the output of the following code? `int x = 0; if (x) { printf(\True\"); } else { printf(\""False\""); }`"""
-
29. What will be the output of the following code? `int x = -5; if (x) { printf(\True\"); } else { printf(\""False\""); }`"""
-
30. Can the 'case' values in a 'switch' statement be of 'char' data type?
-
31. What happens if the 'default' case is not the last case in a 'switch' statement?
-
32. What is the output of the following code? `int a = 10, b = 5; if (a > b) printf(\A is greater\");`"""
-
33. What is the output of the following code? `int a = 5, b = 10; if (a > b) printf(\A\"); else printf(\""B\"");`"""
-
34. What is the output of the following code? `int val = 2; switch (val) { case 1: printf(\One\"); break; case 2: printf(\""Two\""); break; case 2: printf(\""Second Two\""); break; default: printf(\""Other\""); }`"""
-
35. Are 'break' statements optional in every 'case' of a 'switch' statement?
-
36. What will be the output of the following code? `int num = 0; if (num == 0) printf(\Zero\"); else printf(\""Non-zero\"");`"""