1
#include <stdio.h>
#include <math.h>
int main ()
{
int n1, n2, operacao, soma, sub, mult;
float div;
printf("Escolha a opecaracao que deseja realizar: ");
scanf("d", &operacao);
switch(operacao)
{
case 1: '+';
printf("\nInsira N1: "); scanf("%d", &n1);
printf("\nInsira N2: "); scanf("%d", &n2);
soma = n1+n2;
printf("\n%d + %d = %d", n1, n2, soma);
break;
case 2: '-';
printf("\n Insira N1: "); scanf("%d", &n1);
printf("\n Insira N2: "); scanf("%d", &n2);
sub = n1-n2;
printf("\n %d - %d = %d", n1, n2, sub);
break;
case 3: '*';
printf("\n Insira N1: "); scanf("%d", &n1);
printf("\n Insira N2: "); scanf("%d", &n2);
mult = n1*n2;
printf("\n %d X %d = %d", n1, n2, mult);
break;
case 4: '/';
printf("\n Insira N1: "); scanf("%d", &n1);
printf("\n Insira N2: "); scanf("%d", &n2);
div = n1/n2;
printf("\n %d / %d = %.2f", n1, n2, div);
break;
}
return 0;
}
what the operation is doing in front of the case? already tried to remove
'+';
?– Ricardo Pontual
The program compiles with the line
scanf("d", &operacao);
? Or even do theswitch
with aint
?– Fábio Morais