Answer to Question #287072 in C++ for adamsir

Question #287072

create a c++ program that will perform for basic mathematical operation. Design the program to choose which operation to use, then ask the user to enter two values which will be used in computation.


1
Expert's answer
2022-01-12T12:37:51-0500
#include<conio.h>
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include <cmath>
#include<dos.h>
#include <bits/stdc++.h> 
#include<vector>
using namespace std;


int main()
{
	int a,b,Flag=1;
	
	while(Flag)
	{
		cout<<"\n\tPress-1 for Addition";		
		cout<<"\n\tPress-2 for Substraction";		
		cout<<"\n\tPress-3 for Multiplication";		
		cout<<"\n\tPress-4 for Division";		
		cout<<"\n\tPress-0 to QUIT";		
		cout<<"\n\tEnter Option (0 to 4): "; cin>>Flag;
		if(Flag>0)
		{
			cout<<"\n\tEnter a: "; cin>>a;
			cout<<"\n\tEnter b: "; cin>>b;
		}
		if(Flag==1)
		{
			cout<<"\n\t"<<a<<" + "<<b<<" = "<<a+b;
		}
		if(Flag==2)
		{
			cout<<"\n\t"<<a<<" - "<<b<<" = "<<a-b;
		}
		if(Flag==3)
		{
			cout<<"\n\t"<<a<<" * "<<b<<" = "<<a*b;
		}
		if(Flag==4)
		{
			cout<<"\n\t"<<a<<" / "<<b<<" = "<<a/b;
		}
		if(Flag==0) exit(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