Sunday, December 7, 2014

Write a program performing as calculator which allows all Arithmetic Operators with operands as input

#include<iostream>
using namespace std;
main ()
{
int a,b,result;
string arithmatic;
cout<<"the first value:";
cin>>a;
cout<<"the second value:";
cin>>b;
cout<<"apply some artimatic operations /, *, + or - :";
cin>>arithmatic;
if (arithmatic="/" )
result=a/b;
cout<<"a / b ="<<result;
if (arithmatic = "*")
result=a*b;
cout<<"a * b ="<<result;
if (arithmatic = "+")
result = a + b;
cout<<"a+b ="<<result;
if (arithmatic = "-")
result = a-b;
cout<<"a-b ="<<result;
else
cout<<"how is that? enter the value use arithmatic operations!";

return 0;
}

No comments:

Post a Comment