Answer to Question #267973 in C for Samara Serenity

Question #267973

Create a program of mathematical that will display the sum, difference, product, quotient of two variables using the interactive input.


1
Expert's answer
2021-11-18T06:46:16-0500
#include <stdio.h>
#include <stdlib.h>


int main()
{


	int ch=-1;
	float number1;
	float number2;
	float sum;
	float difference;
	float product;
	float div;




	while(ch!=5){
		printf("MENU OF OPERATIONS\n");
		printf("[ 1 ] - Addition\n");
		printf("[ 2 ] - Subtraction\n");
		printf("[ 3 ] - Multiplication\n");
		printf("[ 4 ] - Division\n");
		printf("[ 5 ] - Quit\n");
		printf("Enter Your Choice: ");
		scanf("%d",&ch);
		if(ch==1){
			printf("You have chosen Addition!\n");
			printf("Enter the number 1: ");
			scanf("%f",&number1);
			printf("Enter the number 2: ");
			scanf("%f",&number2);
			sum=number1+number2;
			printf("Sum = %.2f\n\n",sum);
		}else if(ch==2){
			printf("You have chosen Subtraction!\n");
			printf("Enter the number 1: ");
			scanf("%f",&number1);
			printf("Enter the number 2: ");
			scanf("%f",&number2);
			difference=number1-number2;
			printf("Difference = %.2f\n\n",difference);
		}else if(ch==3){
			printf("You have chosen Multiplication!\n");
			printf("Enter the number 1: ");
			scanf("%f",&number1);
			printf("Enter the number 2: ");
			scanf("%f",&number2);
			product=number1*number2;
			printf("Product = %.2f\n\n",product);
		}else if(ch==4){
			printf("You have chosen Division!\n");
			printf("Enter the number 1: ");
			scanf("%f",&number1);
			printf("Enter the number 2: ");
			scanf("%f",&number2);
			div=(float)number1/(float)number2;
			printf("Quotient = %.2f\n\n",div);
		}else if(ch==6){


		}else{
			printf("Wrong menu item.\n\n");
		}
	}
	


	getchar();
	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