#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 |
Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.
what is the diffrenet bettwen HTTP and internet protocol
wat is the difference between array and pointer?
What is difference between structure and union in c programming?
wat is output of the following int main() { const int j=2; int i; switch(i) { case 1:break; case j:break; default:break; } }
please give me some tips for the placement in the TCS.
What is self-referential structure in c programming?
1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. The Logic should be written in Data Structures?
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
How can I increase the allowable number of simultaneously open files?
macros and function are related in what aspect? a)recursion b)varying no of arguments c)hypochecking d)type declaration
12 Answers HCL, Infosys, Microsoft,
What is the difference between int main and void main in c?