Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 35

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 104

Answer:

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


Answer:
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.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 35 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: