|
#include<stdio.h>
#include<cstdlib>
int main()
{
float a,b,c;
char ch;
scanf("%f %f %c",&a,&b,&ch);
switch(ch)
{
case '-':c=a-b;break;
case '*':c=a*b;break;
case '+':c=a+b;break;
case '/':
if(b==0)
{
printf("Divided by zero!");
system("pause");
return 0;
}
else
{
c=a/b;
}
default:printf("Invalid operator!");
}
printf("%f",c);
return 0;
}
|
|