Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(void){
  3. double d1;
  4. double d2;
  5. char operation;
  6.  
  7. int result;
  8.  
  9. printf("Digit 1: ");
  10. scanf("%lf", d1);
  11.  
  12. printf("Operation: |+|-|*|/|");
  13. scanf("%c", operation);
  14.  
  15. printf("Digit 2: ");
  16. scanf("%lf", d2);
  17.  
  18. switch(operation){
  19. case '+':
  20. result = d1 + d2;
  21. break;
  22.  
  23. case '-':
  24. result = d1 - d2;
  25. break;
  26.  
  27. case '*':
  28. result = d1 * d2;
  29. break;
  30.  
  31. case '/':
  32. result = d1 / d2;
  33. break;
  34.  
  35. default:
  36. printf("Error");
  37. }
  38.  
  39. printf("Result: " + result);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement