Question 11832 – Artificial-intelligence
April 14, 2024Programming
April 14, 2024Programming
Question 20 |
What will be the output of the following C program segment?
char inchar = 'A'; switch (inchar) { case 'A' : printf ("choice A n") ; case 'B' : printf ("choice B ") ; case 'C' : case 'D' : case 'E' : default: printf ("No Choice") ; }
No Choice | |
Choice A | |
Program gives no output as it is erroneous |
Question 20 Explanation:
Everything in the switch will be executed, because there is no break; statement after case ‘A’. So it executes all the subsequent statements until it find a break;
So,
→ Choice A
→ Choice B. No choice. Is the output.
So,
→ Choice A
→ Choice B. No choice. Is the output.
Correct Answer: C
Question 20 Explanation:
Everything in the switch will be executed, because there is no break; statement after case ‘A’. So it executes all the subsequent statements until it find a break;
So,
→ Choice A
→ Choice B. No choice. Is the output.
So,
→ Choice A
→ Choice B. No choice. Is the output.
Subscribe
Login
0 Comments