#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 |
Is c compiled or interpreted?
why little endian and big endian came?y they using differently? y they not used commonly ?wt is application of little and big ?
Why is c called c?
can we print any string without using terminator?
Dont ansi function prototypes render lint obsolete?
What are the advantages of using linked list for tree construction?
What is break statement?
what is the differnce between AF_INET and PF_INET?
5 Answers Systems Plus, Wipro,
what is the answer for it main() { int i; clrscr(); printf("%d",&i)+1; scanf("%d",i)-1; }
What type is sizeof?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
How can I write data files which can be read on other machines with different word size, byte order, or floating point formats?