View Single Post
  #5 (permalink)  
Old November 3rd, 2006, 09:24 AM
Geo121 Geo121 is offline
Friend of Wrox
 
Join Date: Jan 2006
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Geo121
Default

There is also the problem of declaring your main function as a void return value

You should always declare main as int because of the way the program returns

it should return a 0 or a 1

0 for complete or 1 for errors

Your code should look like this :

// mastrgamr's simple calculator!
#include <iostream.h>

int main()
{
     cout<<"to use my calculator follow the first command then u must hold shift and either A to add, S to subtract, M to multiply, or D to divide. insert another number and your answer should appear!"<< endl;
     float num2;
     float num1;
     char op;
     //char (op==65 && op==83 && op==77 && op==68) just keep this documentation it isn't required

     float ans;
     cout << "insert number: ";
     cin >> num1;
     cin >> op;
     cin >> num2;
     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 << "=" << ans << endl;

     return 0;
}


~ Geo

 ~ You are unique, just like everyone else
Reply With Quote