#include
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
Answers were Sorted based on User's Feedback
Answer / surenda pal singh chouhan
Compiler Error: Constant expression required in function
main.
Explanation:
The case statement can have only constant expressions (this
implies that we cannot use variable names directly so an
error).
Note:
Enumerated types can be used in case statements.
Is This Answer Correct ? | 10 Yes | 2 No |
Answer / subha raman
yeah..itz mainly syntax error..
there shud not be any declaration of variables..in
case "j"..it must be "case 2"only..
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / pravin
if we use the single qutoes' 'at 1 and j the rest of
program is right because we already decleared the value of i
and i=1 .
so output should be "GOOD" only. (without" ")
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / moolshankershukla
#include
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
given above program is wrong only we can one changes and
will be run .
correct program is:
#include
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case 2: printf("BAD");
break;
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
Compiler Error: Constant expression required in function
main
instead of using j u we can use case 'j' .
this is correct answer
Is This Answer Correct ? | 5 Yes | 5 No |
Can you please explain the difference between strcpy() and memcpy() function?
What is FIFO?
Add Two Numbers Without Using the Addition Operator
What’s the special use of UNIONS?
? ???Mirror Mirror on the wall????????
What is the difference between GETS();AND SCANF();
What is the difference between array and linked list in c?
Program to find the value of e raised to power x using while loop
wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain
how can i get this by using for loop? * ** * **** * ******
main() { int a = 65; printf(“%d %o %x”,a,a,a); } Output 65 101 41 Please explain me.How it is coming like that?
void main() { int i=5; printf("%d",i++ + ++i); }