--
  1. #include "stdio.h"  
  2. int main()  
  3. {  
  4.     char operator;  
  5.     double operand1, operand2, result;  
  6.     char continueCalculation = 'y';  
  7.     while (continueCalculation == 'y')   
  8.     {  
  9.         scanf("%lf %c %lf", &operand1, &operator, &operand2);  
  10.         switch (operator)  
  11.         {  
  12.         case '+':  
  13.             result = operand1 + operand2; break;  
  14.         case '-':  
  15.             result = operand1 - operand2; break;  
  16.         case '*':  
  17.             result = operand1 * operand2; break;  
  18.         case '/':  
  19.             if (operand2 != 0)  
  20.             {  
  21.                 result = operand1 / operand2;  
  22.             }  
  23.             else  
  24.             {  
  25.                 printf("Error (Division by zero)\n");  
  26.                 continue;  
  27.             }  
  28.             break;  
  29.         default:  
  30.             printf("Error (Invalid operator)\n");  
  31.             continue;  
  32.         }  
  33.         printf("%.2lf %c %.2lf = %.2lf\n", operand1, operator, operand2, result);  
  34.         scanf(" %c", &continueCalculation);  
  35.     }  
  36.     return 0;  
  37. }