Welcome Guest | Sign in | Register
Switch-case - Discussion Page For Q.10616 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Switch-case > Questions and Answers

Q: What will be the output of the following program?
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
A. GOOD B. BAD
C. Compiler Error D. No Output

Answer and Explanation

Answer:Compiler Error

Explanation:

Compiler Error: Constant expression required in function main.
The case statement can have only constant expressions .Enumerated types can be used in case statements.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.