View Single Post
  #1 (permalink)  
Old January 19th, 2014, 04:43 AM
quarantined_coder quarantined_coder is offline
Registered User
 
Join Date: Jan 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple C++ Calculator | Cant find the error! Where am i wrong?

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!
Reply With Quote