Comprog (Sulian0, Mike Lowin C.) - Calculator
Comprog (Sulian0, Mike Lowin C.) - Calculator
h>
int main(){
char op;
double first, second;
printf("Input the Operator (+, -, *, /): ");
scanf(" %c", &op);
printf("Enter the two numbers (Note: Do Not Put an integer between the numbers
(Ex. 20 30): ");
scanf("%lf %lf", &first, &second);
switch (op)
{
case '+':
printf("%.2lf + %.2lf = %.2lf",first,second,(first+second));
break;
case '-':
printf(".2%lf - %.2lf = %.2lf",first,second,(first-second));
break;
case '*':
printf(".2%lf * %.2lf = %.2lf",first,second,(first*second));
break;
case '/':
if (second != 0.0)
printf(".2%lf / %.2lf = %.2lf",first,second,(first/second));
else
printf("Divide by Zero Situation");
break;
default:
printf("Invalid");
}
return 0;
}