Calculator


SUBMITTED BY: Guest

DATE: May 21, 2013, 1:33 p.m.

FORMAT: Text only

SIZE: 510 Bytes

HITS: 6371

  1. #include <stdio.h>
  2. int main()
  3. {
  4. float num1, num2;
  5. char operation;
  6. while (1) {
  7. scanf("%f%c%f", &num1, &operation, &num2);
  8. if (operation == '+')
  9. printf("%f\n", num1+num2);
  10. if (operation == '-')
  11. printf("%f\n", num1-num2);
  12. if (operation == '*')
  13. printf("%f\n", num1*num2);
  14. if (operation == '/')
  15. printf("%f\n", num1/num2);
  16. }
  17. return 0;

comments powered by Disqus