I mean i want to add a character next to c in order to enter c or C .
switch (x)
{
case ('c') :
printf("Donnez vous le cote du carre:");
scanf("%f",&cote);
printf("La surface du carre est %f",cote*cote);
break;
CodePudding user response:
It's pretty straightforward. Note that any statements between the two case statements will be executed for a lower case 'c' but not for uppercase. Also note that the parentheses are unnecessary. The expression 'c'
evaluates to the value of the character constant, which is what you want to compare to the value of x
, whether or not the parentheses are present.
case 'c' :
// fall through
case 'C' :
printf("Donnez vous le cote du carre:");
scanf("%f",&cote);
printf("La surface du carre est %f",cote*cote);
break;