#include <stdio.h>
int main()
{
char c;
double a,b;
printf("Operation signs:\n\tFor Addition\t\t: \tPress '+'\n\tFor subtraction \t: \tPress '-'\n\tFor multiplication \t: \tPress '*'\n\tFor division\t\t: \tPress '/' \n\nSelect an operation:\n");
scanf("%c",&c);
printf("Enter a number:\n");
scanf("%lf",&a);
printf("Enter another number: \n");
scanf("%lf",&b);
switch(c)
{
case '+':
printf("%.1lf + %.1lf = %.1lf",a, b, a + b);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf",a, b, a - b);
break;
case '*':
printf("%.1lf * %.1lf = %.1lf",a, b, a * b);
break;
case '/':
printf("%.1lf / %.1lf = %.1lf",a,b, a/b);
break;
default:
printf("Error!");
}
return 0;
}
Comments
Post a Comment