What will be the output of the following program?
#include<stdio.h>
void main()
{
int a=2;
switch(a)
{
case 1:
printf(“One\n”);
break;
case 2:
printf(“Two\n”);
break;
default:
printf(“Else\n”);
break;
}
}
a.
One
b.
error
c.
Two
d.
none
Answers
Answered by
3
The output will be Two.
Explanation:
a is assigned the value 2. The switch statement will run the code under case 2 and exit.
Similar questions