So, what do you guys think of my first C++ program?

Thelis

Golden Master
Messages
5,410
Opinions? Ways to streamline it? If any of you guys know a bit of C++, I would love to ask a few questions.

Code:
#include <iostream>

using namespace std;

int main()
{
int age;
 cout<<"Please input your age, if you want to take an IQ test, type in 100001:";
 cin>>age;
 cin.ignore();
if ( age < 40) {
     cout<<"You are preeety young!\n";
}


else if ( age > 40 && age < 80 ) {
    cout<<"You are getting old\n";

}

else if ( age > 80 && age <110) {
    cout<<"You are really old\n";
}
else if ( age >110 && age <150) {
    cout<<"You are FUCKING ANCIENT\n";

}
while (age>150)
    cout<< "WTF HAX?" << endl;

int a;
int b;
int c;

if (age= 100001)

    cout<<"I want to see if you can do multiplication\n";
    cout<< "Give me two numbers separated by a space:\n";
    cin >> a >> b;
    cin.ignore();
    cout<< "Now, multiply them and tell me what you get:";
    cin >> c;
    cin.ignore();

    if ( c == a*b ) {
    cout<< "Good Job, you are almost as smart as a 3 year old.";
    }
    else {
    cout<<"You are a failure"; }


    cin.get();}
 
So if I'm exactly 40, 80, 110, or 150 years of age I don't get a nice message? :(
Not to mention if you put in 100001 as your age, you're gonna get spammed with WTF HAX
 
Putting an equal sign after less than or greater to signs makes the statement read as less than or equal to, or greater than or equal to.

If and else statements are powerful underlying concepts of C++. Basic but functional. Now onto 'For' 'While' and 'do' for you!

I wrote a program that could do my physics homework for me using pretty much a complex string of if and while statements.

Also I find that if you make programs that you have use for other than novelty programs you find yourself staying motivated.
 
So if I'm exactly 40, 80, 110, or 150 years of age I don't get a nice message? :(
Not to mention if you put in 100001 as your age, you're gonna get spammed with WTF HAX

No you don't.... You get to the multiplication part.

If you put in a value larger than 150 years of age you get a WTF HAX due to the fact that no one can live that long... If you ask a lot of the members on this forum, you will realize that WTF HAX is a joke.

@ red beard, Thanks for the tips. I am starting my for, while and do strings now.
 
ah c++ what a pain in the ass that was i suppose your taking it as a class right? wait until you get up to towers of hanoi. you will hate your life.
 
Nice :) Reminds me of a program I tried to create in Basic using Dark Basic when I got that a while back. I found I couldn't get my head around it though to be honest.
 
That's cool Thelis. How hard is it to learn...seriously? I was thinking about taking a programming class in the fall and would like to know if it is really a nightmare to get started in.
 
You can be like me and copy and paste into a program like Bloodshed DevC++, compile it and run it.

Great job, thelis, compiled and ran with no errors, and does just what it says its going to do. Now to program a game better than Crysis. Get to work! lol...

Yeah, your program was great.. I typed in 20000 the first time... WTF HAX!
 
Back
Top Bottom