TCS
Company
Programming
Variables
Predict the output of following code:
main()
{
int a=2;
switch(a)
{
case 1: printf(“one”);
case 2: printf(“Two”);
// Executable code ; No break statement
case 3: printf(“Three”);
default:printf(“Invalid option”);
}
}
1. onetwothree
2. Invalid option
3. one two
4. None of these
Read Solution (Total 6)
-
- The answer is two three invalid option. As no break statement is present.
- 6 years agoHelpfull: Yes(10) No(0)
- since there is no break in switch case meet at 2 and executed till the default two three invalid is an answer
- 6 years agoHelpfull: Yes(3) No(0)
- two three invalid option
- 6 years agoHelpfull: Yes(2) No(0)
- none of these
- 6 years agoHelpfull: Yes(1) No(0)
- ans:TwoThreeInvalid option
- 6 years agoHelpfull: Yes(1) No(0)
- 4) none of these
-> oneTwoInvalid option - 5 years agoHelpfull: Yes(0) No(2)
TCS Other Question