This is an older version of a calculator that I made when I was just srated. Look around and find some snippets you might like to see how they work or add to yours. For example use of the if statement for displaying an error message, and having a repeating loop asking if a person wants to use the calculator again.
[PHP]
#include
using namespace std;
int main()
{
float num1;
float num2;
char op;
float result;
char again = 'y';
while (again == 'y')
{
cin >> num1;
cout <<"\n num 1 = " << num1 << endl;
cin >> num2;
cout << "\n num2 = " << num2 << endl;
cout <<"\n Now enter an operating symbol (+ - / *)"<> op;
if (op == '+')
cout << "\n num1 + num2 = " << num1 + num2 << endl;
if (op == '-')
cout <<"\n num1 - num2 = " << num1 - num2 << endl;
if (op == '*')
cout <<"\n num1 * num2 = " << num1 * num2 << endl;
if (op == '/')
cout << " \n num1 / num2 = " << num1 / num2 << endl;
if (op == '2')
cout <<" \n num1 to the second power = " << num1 * num1 << endl;
if (op == '3')
cout <<" \n num1 to the third power = " << num1 * num1 * num1 << endl;
else
cout << "\n Invalid Operation";
cout << "\n Do you want to try again? (y/n): ";
cin >> again;
}
return 0;
}[/PHP]