Very basic Calculator program in C++

in #programming6 years ago

 Program

A program is set of instruction given by user to computer to perform a specific task.computer program, in depth intend or else process in lieu of solving a riddle by means of a computer; supplementary specifically, an unambiguous, well thought-out string of computational advice indispensable near attain such a solution.  

Program Body:

#include< math.h>am  >
#include< math.h >
using namespace std;
class calculator{
private:
double first,scnd,result;
char op;
public:
void cal(){
cout<<"Enter your first value "<<endl;
cin>>first;
cout<<"put any basic operator "<<endl;
cin>>op;
cout<<"Enter your second value"<<endl;
cin>>scnd;
if(op=='+'){
        result=first+scnd;
    cout<<"your result is "<<result<<endl;
}
else if(op=='-')
    {
result=first-scnd;
cout<<"your result is "<<result<<endl;
}
else if(op=='*')
{
result=first*scnd;
cout<<"Your result is "<<result<<endl;
}
else if(op=='/')
{
result=first/scnd;
cout<<"your result is "<<result<<endl;
}
}
};
int main(){
calculator object;
object.cal();
}

 

Written in C++

Source

Made in Visual C++ IDE

Source

 I hope it was helpful and you learned something from it, Thanks

Coin Marketplace

STEEM 0.20
TRX 0.12
JST 0.029
BTC 61657.19
ETH 3452.67
USDT 1.00
SBD 2.52