#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 |
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
can we print any string in c language without using semicolon(;)(terminator) in whole program.
What is new line escape sequence?
how can I convert a string to a number?
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
What is the output of the below program and how it is? void main() { static int var=5; printf("%d",var--); if(var) main(); }
8 Answers MindFire, TCS, Tech Mahindra,
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
Explain what is the benefit of using #define to declare a constant?
Which is best linux os?
What are the 3 types of structures?
what is the most appropriate way to write a multi-statement macro?
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it?