Thread: Your first post.

  1. #31
    Rad gcn_zelda's Avatar
    Join Date
    Mar 2003
    Posts
    942
    Code:
    #include <iostream.h>
    #include <windows.h>
    
    int main()
    {
    cout << "Stephen's C++ Calculator" << endl;
    cout << "Enter a number" << endl;
    int a;
    cin << a;
    cout << a << endl;
    cout << "Now push a math sign" << endl;
    int sign;
    cin << sign;
    cout << a <<""<< sign << endl;
    cout << "Now push a second number" << endl;
    int b;
    cin << b;
    if (sign == " + ");
    {
    int resultplus;
    a + b = resultplus;
    cout << resultplus << " is your answer!" << endl;
    }
    if(sign == " - ");
    {
    int resultminus;
    a - b = resultminus;
    cout << resultminus << " is your answer!" << endl;
    }
    if(sign == "/");
    {
    int resultdivide;
    a / b = resultdivide;
    cout << resultdivide << " is your answer!" << endl;
    }
    if(sign == "*");
    {
    int resultmultiply;
    a * b = resultmultiply;
    cout << resultmultiply << " is your answer!" << endl;
    }
    return 0;
    }
    It hurts me to admit that I actually posted this...

    Edit: At least I can say my stupidity wasn't all my fault. I learned to declare variables from the RPGToolkit, so that's why I didn't declare them at the beginning of the main function. The RPGToolkit also didn't require variable initialization.

    The reason I didn't use the standard headers is because I was using an outdated C++ book which, frankly, sucked.
    Last edited by gcn_zelda; 11-11-2005 at 04:47 PM.

  2. #32
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    http://cboard.cprogramming.com/showthread.php?t=16931

    I think I posted a few under guest
    What is C++?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help (Trying to post message)
    By mrkm in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-06-2003, 04:05 PM
  2. Post your Best Text Adventure
    By Joe100 in forum Game Programming
    Replies: 3
    Last Post: 08-15-2003, 05:47 PM
  3. Auto POST
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 06-07-2003, 10:42 AM
  4. post update
    By iain in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-12-2001, 10:47 AM