#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

Does c have circular shift operators?

734


Why we not create function inside function.

1753


What is context in c?

543


What are the 4 types of programming language?

587


What do you mean by invalid pointer arithmetic?

637






How do you list a file’s date and time?

637


Can we declare variable anywhere in c?

539


write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.

4992


Write a program to know whether the input number is an armstrong number.

675


Why do we use static in c?

636


What is indirection? How many levels of pointers can you have?

664


Why is c still so popular?

620


What happens if a header file is included twice?

602


What is the stack in c?

723


What functions are used in dynamic memory allocation in c?

599