How to make a calculator in C++

Well if you have read the previous tutorial “How to make a calculator in C

The program goes like this below

#include<iostream.h>
#include<conio.h>
int main()
{
int a, b, s,o;
cout<<“Enter the value of A “;
cin>>a;
cout<<“Enter the value of B “;
cin>>b;
cout<<“Enter what operator will be used + – * /”;
cin>>o;
if(o=+)
{
s=a+b;
}
else if(o=-)
{
s=a-b;
}
else if(o=*)
{
s=a*b
}
else if(o=/)
{
s=a/b;
}
else
{
cout<<“Entered Operator Does Not Exist”
}
cout<<“The value calculated value is “<<s;
return 0;
}

 

Thanks for reading, share a little bit 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *