Monday, February 15, 2010

21

#include < stdio.h >
main()
{
float a=1;
switch(a)
{
case 1:
printf("%f",a);
break;
case 1.0:
printf("%f",a);
break;
default:
printf("%f",a);
}
return 0;
}


Output


Compilation Error:
Switch Selection expression must be integral type.
Constant expression required


Logic:



Switch Selection expression must be integral type:
we can give only integer or characters variable to switch case.

Constant expression required:
we can use only integer constants or characters in case.

0 comments:

Post a Comment