Go Back   Computer Forums > Welcome To Computer Forums .org > Social Lounge | Off Topic
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 02-04-2008, 05:42 PM   #1
Golden Master
 
Thelis's Avatar
 
Join Date: Mar 2007
Posts: 5,410
Send a message via AIM to Thelis Send a message via MSN to Thelis Send a message via Yahoo to Thelis
Default So, what do you guys think of my first C++ program?

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();}
__________________

Thelis is offline   Reply With Quote
Old 02-04-2008, 07:23 PM   #2
In Runtime
 
Join Date: Oct 2007
Posts: 333
Default Re: So, what do you guys think of my first C++ program?

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
__________________

TheLastWolf is offline   Reply With Quote
Old 02-04-2008, 07:32 PM   #3
Daemon Poster
 
mayorredbeard's Avatar
 
Join Date: Nov 2004
Posts: 1,246
Default Re: So, what do you guys think of my first C++ program?

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.
__________________
Karma/rep is always appreciated
01010010011001010110010001100010011001010110000101 11001001100100
010011110111010101110100

There are only 10 kinds of people in this world. Those who can read binary, and those who can't.
mayorredbeard is offline   Reply With Quote
Old 02-04-2008, 07:38 PM   #4
Golden Master
 
Thelis's Avatar
 
Join Date: Mar 2007
Posts: 5,410
Send a message via AIM to Thelis Send a message via MSN to Thelis Send a message via Yahoo to Thelis
Default Re: So, what do you guys think of my first C++ program?

Quote:
Originally Posted by TheLastWolf View Post
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.
Thelis is offline   Reply With Quote
Old 02-04-2008, 08:14 PM   #5
Fully Optimized
 
Join Date: Oct 2005
Location: 1
Posts: 2,525
Default Re: So, what do you guys think of my first C++ program?

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.
Ronco Rox is offline   Reply With Quote
Old 02-04-2008, 08:18 PM   #6
Golden Master
 
Kage's Avatar
 
Join Date: Nov 2004
Posts: 13,873
Send a message via MSN to Kage
Default Re: So, what do you guys think of my first C++ program?

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.
__________________
Abit IP35 Pro / Q6600 G0 / Zalman 9700 / 8800GTS 640mb / 4x 2GB Corsair XMS / X-FI Xtreme M / 1x 1TB / Antec 900 / Logitech Z-5500 / Samsung 20inch
Kage is offline   Reply With Quote
Old 02-04-2008, 08:52 PM   #7
Daemon Poster
 
iamchickenlover's Avatar
 
Join Date: Jan 2008
Posts: 821
Default Re: So, what do you guys think of my first C++ program?

very nice. your school has programming classes?
iamchickenlover is offline   Reply With Quote
Old 02-04-2008, 09:32 PM   #8
In Runtime
 
MacGirl's Avatar
 
Join Date: Jan 2008
Posts: 193
Default Re: So, what do you guys think of my first C++ program?

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.
MacGirl is offline   Reply With Quote
Old 02-04-2008, 09:44 PM   #9
Fully Optimized
 
_-..zKiLLA..-_'s Avatar
 
Join Date: Nov 2007
Posts: 3,952
Send a message via AIM to _-..zKiLLA..-_
Default Re: So, what do you guys think of my first C++ program?

wtf... not too be a noob but what do i do with the code?
__________________
My beast lappy: Acer netbook, 1.6ghz atom dual core, 2gb ddr3
My PSN: Kalikid_420
_-..zKiLLA..-_ is offline   Reply With Quote
Old 02-04-2008, 09:48 PM   #10
Fully Optimized
 
FlightSimBoy's Avatar
 
Join Date: Jun 2007
Posts: 2,114
Send a message via AIM to FlightSimBoy
Default Re: So, what do you guys think of my first C++ program?

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!
__________________

__________________
My Computer: eMachines T5226 - Intel Pentium D Dual Core @ 3 GHz - Diamond Viper Radeon HD3870 OC Edition with 1 GB GDDR3 VRAM - 4 GB PQi Turbo DDR2-533 RAM - Corsair 650W PSU with 52A on single rail - TSSTcorp DVD-DL+-RW combo drive - Lite-on 52x CD-RW burner - Creative SoundBlaster X-Fi XtremeGamer - Logitech z5300e speakers - WinFast TV Tuner - Vista Ultimate 64-Bit. eBay name: Flightsimboy304
FlightSimBoy is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:41 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0