Wednesday, 8 July 2015

Simple Calculator in C++

#include<iostream>
using namespace std;
int main()
{
char op;
double a,b,c;
do{
cout<<"\t\t\t\"Calculator\" \n";
cout<<"Enter first value: ";
cin>>a;
cout<<"Enter operator... +, -, /, * ... ";
cin>>op;
cout<<"Enter second value: ";
cin>>b;
if(op=='+') c=a+b;
if(op=='-') c=a-b;
if(op=='*') c=a*b;
if(op=='/') c=a/b;
cout<<"The Answer is: "<<c<<"\n\n";
cout<<"--------------------------------------------------------------"<<"\n\n";
  }while(op!='d');
return 0;
}

0 comments:

Post a Comment