SIMPLE C++ Calculator from the book "Beginning Programming" ...
Code:
// C++ Calculator
#include <iostream.h>
void main()
{
float num1;
float num2;
char op;
float ans;
cout << "Please enter a number: ";
cin >> num1;
cout << "Please enter another number: ";
cin >> num2;
cout << "Press A to add the two numbers." ;
<< endl
<< "Press B to subtract the two numbers"
<< endl
<< "Press C to multiply the two numbers"
<< endl
<< "Press D to divide the two numbers"
<< endl
cin >> op;
if (op == 65)
ans = num1 + num2;
if (op == 83)
ans = num1 - num2;
if (op == 77)
ans = num1 * num2;
if (op == 68)
ans = num1 / num2;
cout << "The answer is " << ans << endl;
}
It dosent compile! Cant find the error! Please help me!