Hey there assassins, welcome to cyber assassins a couple days ago our admin Lyc posted the same code
but i have fixed some bugs. so here is the code:
#include <stdio.h>
int main()
{
char operation;
double a, b;
printf("Enter the first number\n");
scanf("%lf", &a);
printf("Enter the operation you want to do. It must be * / + - x ÷\n");
scanf(" %c", &operation);
printf("Enter the second number\n");
scanf("%lf", &b);
switch (operation)
{
case '+':
printf("%0.1lf+%0.1lf=%0.1lf\n", a, b, a+b);
break;
case '*':
printf("%0.1lfx%0.1lf=%0.1lf\n", a, b, a*b);
break;
case '-':
printf("%0.1lf-%0.1lf=%0.1lf\n", a, b, a-b);
break;
case '/':
printf("%0.1lf÷%0.1lf=%0.1lf\n", a, b, a/b);
break;
case 'x':
printf("%0.1lfx%0.1lf=%0.1lf\n", a, b, a*b);
break;
case '÷':
printf("%0.1lf÷%0.1lf=%0.1lf\n", a, b, a/b);
break;
default:
printf("Please enter a valid oparator such as * / + - x ÷\n");
}
return 0;
}
0 comments:
Post a Comment