C
Programming and Technical
Programming
What will be the output for the following C program ..??
void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}
Read Solution (Total 5)
-
- Compile Time Error as case 2 & 3 are outside the switch and case 4 is unreachable.
- 10 years agoHelpfull: Yes(5) No(0)
- the output is 1234
because 3 cases are within for
and 4 would be on case 4.
Hence prints 1234 as output - 10 years agoHelpfull: Yes(4) No(2)
- break is not within the loop or switch error
- 10 years agoHelpfull: Yes(1) No(0)
- compile error leads case 2,3 are out of scope
- 10 years agoHelpfull: Yes(0) No(0)
- I will print 4
- 10 years agoHelpfull: Yes(0) No(0)
C Other Question