#include<stdio.h>

main()

{

int i=1,j=2;

switch(i)

{

case 1: printf("GOOD");

break;

case j: printf("BAD");

break;

}

}



#include<stdio.h> main() { int i=1,j=2; switch(i) ..

Answer / susie

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.

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Code Interview Questions

func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }

1 Answers   Satyam,


Is it possible to type a name in command line without ant quotes?

1 Answers   Excel, Infosys,


Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);

1 Answers  


¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


Write a Program in 'C' To Insert a Unique Number Only. (Hint: Just Like a Primary Key Numbers In Database.) Please Some One Suggest Me a Better Solution for This question ??

0 Answers   Home,






main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); }

1 Answers  


struct point { int x; int y; }; struct point origin,*pp; main() { pp=&origin; printf("origin is(%d%d)\n",(*pp).x,(*pp).y); printf("origin is (%d%d)\n",pp->x,pp->y); }

1 Answers  


plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............

2 Answers   Wipro,


void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  


Write a function to find the depth of a binary tree.

13 Answers   Adobe, Amazon, EFI, Imagination Technologies,


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


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.

9 Answers   Microsoft,


Categories