Your first post.

This is a discussion on Your first post. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Code: #include <iostream.h> #include <windows.h> int main() { cout << "Stephen's C++ Calculator" << endl; cout << "Enter a number" ...

  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 03:47 PM.

  2. #32
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    signiture and alias pic

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

Page 3 of 3 FirstFirst 123
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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21