Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <conio.h>
  3.  
  4. int main()
  5. {
  6.  
  7. double num;
  8. double total = 0.0;
  9. int howmanynum;
  10. int operation;
  11.  
  12. printf("Here ore your options for operations for when you'll need them later:\n");
  13. printf("1 for addition\n2 for subtraction\n3 for multiplication\n4 for division");
  14.  
  15. printf("\n\nNow enter how many numbers are in your math problem: ");
  16. scanf("%d", &howmanynum);
  17.  
  18. printf("\n\nEnter the first number: ");
  19. scanf("%lf", &num);
  20. total = total + num;
  21.  
  22. for(int i = 1; i < howmanynum; i++){
  23.  
  24. printf("\n\nEnter the operation: ");
  25. scanf("%d", &operation);
  26.  
  27. switch(operation)
  28. {
  29. case 1:
  30. total = total + num;
  31. break;
  32.  
  33. case 2:
  34. total = total - num;
  35. break;
  36.  
  37. case 3:
  38. total = total * num;
  39. break;
  40.  
  41. case 4:
  42. total = total / num;
  43. break;
  44. }
  45.  
  46. printf("\n\nEnter the next number: ");
  47. scanf("%lf", &num);
  48. }
  49. printf("\n\nThe total is %lf", total);
  50. printf("\n\nPress any key to exit");
  51.  
  52. getch();
  53. return 0;
  54. }
Add Comment
Please, Sign In to add comment