Answer to Question #274539 in C for zombie

Question #274539

Create a C program 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: 10


1*10=10

2*10=20

3*10=30

4*10=40

5*10=50

6*10=60

7*10=70

8*10=80

9*10=90

10*10=100


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:5


1+5=6

2+5=7

3+5=8

4+5=9

5+5=10

6+5=11

7+5=12

8+5=13

9+5=14

10+5=15



Continue [Y/N]? N


Thank you for choosing my program


1
Expert's answer
2021-12-02T14:16:03-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