Thread: First C++ Programme, Inspection Needed Please?

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    1

    First C++ Programme, Inspection Needed Please?

    Don't know if it's coded to the best or not, as its my first attempt using IF's , but by looking at it I'm sure iv'e made more work for my self then i needed to.

    Feedback please, or anyway I could have made this easier if its possible.


    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
        system("TITLE My First C++ Programme!");
        system("COLOR 04");
        int age; //variables
        int sonsage;
    
        cout << "How Old Are You?";
        cin >> age;
    
        if ( age > 50 )
    
        {
            cout << "your getting old :(!\n";
            cout << "How old is your son?";
        cin >> sonsage;
    
        }
    
        else if ( age < 50 )
    
        {
    
        cout << "Your young :) :)\n";
    
        cout << "How old is your son?";
        cin >> sonsage;
        }
    
    
        if ( sonsage < 10 )
    
        {
            cout << "Wow hes a young man he is!\n";
    
        }
    
        else
    
        {
            cout << "i dont care!!! hahahahahahahahah :)\n";
        }
    }
    Thank you

  2. #2
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    Not a whole lot to say, but if you're always going to ask about the son, the input statements do not need to be in an if-else block.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Those messages are scary...
    If you only care about kids when they're under 10, there's something really wrong with you.

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    You are ... as a contraction ... is YOU'RE not YOUR! Argh!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help me with ma c programme..
    By eddie19 in forum C Programming
    Replies: 19
    Last Post: 08-12-2009, 07:53 AM
  2. Closing a programme with cin.get
    By Dontgiveup in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2009, 02:35 PM
  3. How to view the programme before it disappears
    By yousuf in forum C Programming
    Replies: 2
    Last Post: 03-22-2008, 08:12 AM
  4. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  5. Gui Programme does'nt Compiles from DOS
    By Shadowhunt in forum C++ Programming
    Replies: 1
    Last Post: 06-06-2003, 08:05 AM