#include
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the meaning of keyword 'extern' in a function declaration.

877


What is the translation phases used in c language?

780


In a header file whether functions are declared or defined?

823


How can I remove the trailing spaces from a string?

759


a c code by using memory allocation for add ,multiply of sprase matrixes

2472






How can I avoid the abort, retry, fail messages?

808


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1527


Can we change the value of static variable in c?

701


Explain the use of function toupper() with and example code?

805


Why use int main instead of void main?

771


How can I get the current date or time of day in a c program?

841


In a switch statement, what will happen if a break statement is omitted?

760


What is wrong with this program statement? void = 10;

977


What is the size of enum in c?

783


How are structure passing and returning implemented?

735