First time here? Checkout the FAQ!
x
menu search
brightness_auto
more_vert

What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input).


#include<stdio.h>
void main()
{
int ch;
printf("enter a value between 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\n");
break;
printf("hi");
default:
printf("2\n");
}
}
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer

output will be 1 for case 1


image

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
...