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.
#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);
}
}
Comments
Leave a comment