4
Good morning, I would like to know, why is my calculator program not printing the value of operations?? Below is the code:
#include <stdio.h>
int main (void)
{
float A, B;
char op;
scanf("%f", &A);
scanf("%c", &op);
scanf("%f", &B);
switch('op')
{
case 43 : printf("%f", A + B);
break;
case 45 : printf("%f", A - B);
break;
case 42 : printf("%f", A * B);
break;
case 47 : printf("%f", A / B);
break;
}
return 0;
}
Mete
default
in theswitch
! Turn on as many warnings as possible from your compiler and pay attention to them!– pmg
Remove the quotes from the 'op':
switch(op)
– Lucas
I’ve removed the quotes and you still have the same problem
– Gabriel Vinicius
in the
default
ofswitch
, prints the value ofop
.– pmg
As I said in my reply it is not possible to put strings in the case.
– Ricardo