Answer to Question #274118 in C for tree

Question #274118

Create a C program and a flowchart that will generate a table of chosen mathematical operations. The user has to be prompted first for the math operation and then enter a value that will be used to add, subtract, multiply or divide from 1 to 10 to complete the table. A sample run is provided below to illustrate the output.


M A T H O P E R A T I O N S:

[M] – Multiplication

[D] – Division

[A] – Addition

[S] - Subtraction


Enter your choice: M

Enter your desired value to be multiplied: 7

1*9=9

2*9=18

3*9=27

4*9=36

5*9=45

6*9=54

7*9=63

8*9=72

9*9=81

10*9=90


Continue [Y/N]? Y


M A T H O P E R A T I O N S:

[M] – Multiplication

[D] – Division

[A] – Addition

[S] - Subtraction


Enter your choice: A

Enter your desired value to be added:4


1+6=7

2+6=8

3+6=9

4+6=10

5+6=11

6+6=12

7+6=13

8+6=14

9+6=15

10+6=16


Continue [Y/N]? N

Thank you for choosing my program


1
Expert's answer
2021-12-02T00:35:38-0500
#include<stdio.h>
int main()
{
    int option;
    printf("1.[M] – Multiplication\n2.[D] – Division\n3.[A] – Addition\n4.[S] - Subtraction");
    printf("Enter your choice: ");
    scanf("%d",&option);
    if(option=='M'||option=='m'){
    int j,n;
    printf("Input the number (Table to be calculated) : ");
    scanf("%d",&n);
    printf("\n");
    for(j=1;j<=10;j++)
    {
     printf("%d X %d = %d \n",n,j,n*j);
    }
    }
    else if(option=='D'||option=='d'){
        int j,n;
    printf("Enter your desired value to be divided: ");
    scanf("%d",&n);
    printf("\n");
    for(j=1;j<=10;j++)
    {
     printf("%d / %d = %d \n",n,j,n/j);
    }
    }
    else if(option=='A'||option=='a'){
        int j,n;
    printf("Enter your desired value to be multiplied : ");
    scanf("%d",&n);
    printf("\n");
    for(j=1;j<=10;j++)
    {
     printf("%d + %d = %d \n",n,j,n+j);
    }
    }
    else if(option=='S'||option=='s'){
        int j,n;
    printf("Enter your desired value to subtract : ");
    scanf("%d",&n);
    printf("\n");
    for(j=1;j<=10;j++)
    {
     printf("%d - %d = %d \n",n,j,n-j);
    }
    }
    else{
        printf("Invalid option");
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS