#include <stdio.h>
#include <math.h>
#include <stdlib.h>
/* This is an example program to
   demonstrate the switch
   statement
*/
main()
{
  float val1, val2, result;
  char op, buf[80];;
 
  do {
    printf("Input an expression: ");
    if (scanf("%f%c%f", &val1, &op, &val2) != 3) break;
    switch (op) {
      case '-':
        val2 = -val2;
      case '+':
        result = val1 + val2;
        break;
      case '*':
        result = val1 * val2;
        break;
      case '/':
        result = val1 / val2;
        break;
      case '^':
        result = pow(val1, val2);
        break;
      default:
        printf("Unknown operation\n");
    }
    printf("The result of %f %c %f is %f\n", val1, op, val2, result);
    gets(buf); // clear input
    printf("Do you want to go again? (Y/N) ");
    scanf("%c", &op);
  } while (toupper(op) == 'Y');
  return 0;
}