TCS
Company
Programming
Program
Predict the output of this code snippet?
#include
int main()
{
int i = 3;
switch (i)
{
case 0+1: printf(“Cyber”);
break;
case 1+2: printf(“Tecz”);
break;
default: printf(“CyberTecz”);
}
return 0;
}
A)Cyber B)Tecz C)CyberTecz D)Compiler error
Read Solution (Total 9)
-
- C) CyberTecz
- 3 years agoHelpfull: Yes(3) No(3)
- B)Tecz
because 1+2 = 3 which is i - 3 years agoHelpfull: Yes(1) No(0)
- D)
Complier error - 3 years agoHelpfull: Yes(1) No(0)
- Output is Tecz because I is given as 3 in main statement
- 3 years agoHelpfull: Yes(0) No(0)
- B)Tecz 2+1=3
- 3 years agoHelpfull: Yes(0) No(1)
- B) Tecz
because case 1+2 means case 3 - 3 years agoHelpfull: Yes(0) No(1)
- option B - Tecz
- 3 years agoHelpfull: Yes(0) No(0)
- B)Tecz
bcz i=3 and in case1+2=3 so it print Tecz then exit from loop - 3 years agoHelpfull: Yes(0) No(0)
- Its's compiler error, because we haven't included stdio(standard input output) library
- 3 years agoHelpfull: Yes(0) No(0)
TCS Other Question