Control Flow (if else switch) – Multiple Choice Questions (MCQs)
-
-
38. What will be the output of the following code? `int choice = 'B'; switch (choice) { case 'A': printf(\Apple\"); break; case 'B': printf(\""Banana\""); break; default: printf(\""Fruit?\""); }`"""
-
39. Can you use relational operators in the 'case' conditions of a 'switch' statement?
-
40. What is the purpose of the 'if' statement?
-
41. What is the purpose of the 'else' statement?
-
42. What is the purpose of the 'else if' statement?
-
43. What is the output of the following code? `int value = 1; if (value--) printf(\True\"); else printf(\""False\"");`"""
-
44. What is the output of the following code? `int value = 0; if (value--) printf(\True\"); else printf(\""False\"");`"""
-
45. What is the output of the following code? `int count = 5; if (++count > 5) printf(\Greater\"); else printf(\""Smaller\"");`"""
-
46. What is the output of the following code? `int count = 5; if (count++ > 5) printf(\Greater\"); else printf(\""Smaller\"");`"""
-
47. Can you use logical operators within the condition of an 'if' statement?
-
48. Can you use assignment operators within the condition of an 'if' statement?