Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int main()
- {
- double num;
- double total = 0.0;
- int howmanynum;
- int operation;
- printf("Here ore your options for operations for when you'll need them later:\n");
- printf("1 for addition\n2 for subtraction\n3 for multiplication\n4 for division");
- printf("\n\nNow enter how many numbers are in your math problem: ");
- scanf("%d", &howmanynum);
- printf("\n\nEnter the first number: ");
- scanf("%lf", &num);
- total = total + num;
- for(int i = 1; i < howmanynum; i++){
- printf("\n\nEnter the operation: ");
- scanf("%d", &operation);
- switch(operation)
- {
- case 1:
- total = total + num;
- break;
- case 2:
- total = total - num;
- break;
- case 3:
- total = total * num;
- break;
- case 4:
- total = total / num;
- break;
- }
- printf("\n\nEnter the next number: ");
- scanf("%lf", &num);
- }
- printf("\n\nThe total is %lf", total);
- printf("\n\nPress any key to exit");
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment