Answer to Question #273702 in C for Baby

Question #273702

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

7*1=7

7*2=14

7*3=21

7*4=28

7*5=35

7*6=42

7*7=49

7*8=56

7*9=63

7*10=70


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

4+1=5

4+2=6

4+3=7

4+4=8

4+5=9

4+6=10

4+7=11

4+8=12

4+9=13

4+10=14

Continue [Y/N]? N

Thank you for choosing my program


1
Expert's answer
2021-11-30T18:40:57-0500
#include<stdio.h>
int main(){
	char c;
	do{
		printf("M A T H   O P E R A T I O N S:\n[M] – Multiplication\n[D] – Division\n[A] – Addition\n[S] - Subtraction\n");
		char choice;
		printf("Enter your choice: ");
		int d;
			int x ;
		scanf("%c", &choice);
		switch(choice){
			case 'M':
				printf("Enter your desired value to be multiplied: ");
				
				scanf("%d", &d);
			
				for( x=1; x<=10; x++){
					printf("%d * %d = %d\n", d, x, (x*d));
					
				}
				break;
				
					case 'D':
				printf("Enter your desired value to be divided: ");
			
				scanf("%d", &d);
				
				for(x=1; x<=10; x++){
					printf("%d / %d = %d\n", d, x, (d/x));
					
				}
				break;
				
					case 'A':
				printf("Enter your desired value to be added: ");
				
				scanf("%d", &d);
				
				for( x=1; x<=10; x++){
					printf("%d + %d = %d\n", d, x, (x+d));
					
				}
				break;
				
					case 'S':
				printf("Enter your desired value to be subtracted: ");
				
				scanf("%d", &d);
				
				for(x=1; x<=10; x++){
					printf("%d - %d = %d\n", d, x, (x-d));
					
				}
				break;
				 
		}
		printf("Continue [Y/N]? ");
		scanf("%c", &c);
	}while(c !='N');
}

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