In this post we will create a simple calculator in our program today. The user will enter the first value then he will give the arithmetic operator and then he will give the second value. The compiler will then give the answer against the arithmetic operators, in this program we will learn little bit about TEXT data types.
The complete code of this program is as follows:
The complete code of this program is as follows:
#include <iostream>
using namespace std;
int main (void)
{
int a, b,c ;
char op;
cout << "Enetr the value" <<"\n";
cin >> a ;
cout << "Enter the other value" <<"\n";
cin >> b;
cout << "Enter arethmetic operation" <<"\n";
cin >> op;
if (op == '+')
{cout << a + b;
}
if (op == '-')
{ cout << a - b;
}
if ( op == '/')
{ cout << a / b;
}
if ( op == '*')
{cout << a * b;
}
system ("pause");
return 0;
}
