Previous Thread
Next Thread
Print Thread
Rate Thread
#17347 02/15/03 12:42 AM
Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
hehe finally decided to learn some C++ so started reading and came up with this prb lol = ) Its some were from a tutorial but i wrote it from scratched, and made it shorter with out a ELSE, Just have Else if's = )

What u guys think hehe

heres the link to the little source = )

http://ice.promodtecnologies.com/cpp.html


Good artists copy, great artists
steal.

-Picasso
Joined: Mar 2002
Posts: 1,273
DollarDNS Owner
Offline
DollarDNS Owner
Joined: Mar 2002
Posts: 1,273
#include // of course you need the Include guys = )

that's really nice and all, but you're not including anything. It's just a #include without anything after it. I'm surprised whatever compiler you used doesn't scream at you.

And there's a logic bug in your program. It doesn't do anything if you enter 30.


Domain Registration, Hosting, Management
http://www.dollardns.net
Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
hehe, THis is was my first 30 min working with C++
of course theres gonna be bugs man


Good artists copy, great artists
steal.

-Picasso
Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
Code
#include <iostream.h>

int main()
{
int num;
cout<<"Please Guess the Number 1,2,3,4,5,6,7: ";
cin>>num;
if(num==1)
{
cout<<"Sorry Try Again";
}
else if(num==2)
{
cout<<"Sorry Try Again";
}
else if(num==3)
{
cout<<"Sorry Try Again";
}
else if(num==4)
{
cout<<"Sorry Try Again";
}
else if(num==5)
{
cout<<"Ding Ding That is The Correct Number";
}
else if(num==6)
{
cout<<"Sorry Try Again";
}
else if(num==7)
{
cout<<"Sorry Try Again";
}

int a;
cin >> a;
return 0;
}
Heres another one lol = )
Little longer but simple stuff
Just geting used the Program itself


Good artists copy, great artists
steal.

-Picasso
Joined: Mar 2002
Posts: 71
C
Junior Member
Offline
Junior Member
C
Joined: Mar 2002
Posts: 71
whats the int a at the end for? and thats too many else if statements in my opinion. use a switch case instead. Then again, thats just about style.

tut on switch statements


"If you let your wife stand on your toe tonight, she'll stand on your face tomorrow morning" - Sir/Saint Thomas More

-CryptoKnight-
Joined: Mar 2002
Posts: 71
C
Junior Member
Offline
Junior Member
C
Joined: Mar 2002
Posts: 71
oh, i just read your other program. Thats not how you stop it so you can see it, you are just wasting memory (not like its a lot but hey, its better you dont get used to it now that you are startin to learn).
#include "conio.h"
getch(); //that will pause till you press a key


"If you let your wife stand on your toe tonight, she'll stand on your face tomorrow morning" - Sir/Saint Thomas More

-CryptoKnight-
Joined: Mar 2002
Posts: 1,136
P
UGN Elite Poster
Offline
UGN Elite Poster
P
Joined: Mar 2002
Posts: 1,136
You don't need all those else if's, either... just do:
if(num == 5)
{
cout<<"Ding Ding That is The Correct Number";
}
else
{
cout<"Sorry Try Again";
}

Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Yeh try to keep the code clean and simple, a little space goes a long way...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
Thanks for the Tips, Just started learning on Sunday. man i made it long and it could fit in 5 lines lol = )


Good artists copy, great artists
steal.

-Picasso
Joined: Mar 2002
Posts: 256
Likes: 1
UGN Security Staff
Offline
UGN Security Staff
Joined: Mar 2002
Posts: 256
Likes: 1
heh and CIN and COUT is not included in linux's gcc compiler we have to use g++ smirk

Joined: Mar 1983
Posts: 55
S
UGN Elder
Offline
UGN Elder
S
Joined: Mar 1983
Posts: 55
Thats because gcc is a c compiler where as g++ is a c++ compiler, i have used both, and they are the same except for that one thing.
At any rate, good luck with your programming, its fun, but not usually easy. I've spent the last 2 evens for like 6 hours a day working on my one program so, just be prepared to spend alot of time on it. Don't get discouraged, and ENJOY POINTERS! their your friend...

{Mr. Rage, I plan on showing up to irc tonight, if you could be there, i'd like to have you help me test my program to test requirements if you would please}

Regards,

Skull


Trust me, if i started killing people, there'd None of you left
Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
man looking at this code i posted makes me laught lol

man those programs could have been made in 4-6 lines

I am on Chp.17 Vairiable Scope
i am reading C++ by Example = )


Good artists copy, great artists
steal.

-Picasso
Joined: Aug 2003
Posts: 68
M
Junior Member
Offline
Junior Member
M
Joined: Aug 2003
Posts: 68
maybe you should try to have some fun and have it change the number every time. but hey for being new to programming thats not too bad. took me a long time to get even a little c down.

Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
So c++ i program that lets u do exactly what?

Joined: Mar 2002
Posts: 599
UGN's Resident Homo
Offline
UGN's Resident Homo
Joined: Mar 2002
Posts: 599
don't understand exactly what your asking coleman, try rephrasing it. if you are trying to ask what the above program does, it i just a guessing game. the user enters a number and it tells the user if they got it right or wrong.


"It's better to burn out, than to fade away."
Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
Ok let me try and refrase it for you....Ok so what does this program do for for the user that is using it...like if you do get the number right what happens?

Joined: Mar 2002
Posts: 27
-
Junior Member
Offline
Junior Member
-
Joined: Mar 2002
Posts: 27
coleman, the program just tells u if you got it right or wrong, thats all...nothing more. even if u didnt know c++ u could go through the code and at least figure that part out


-=Toxic Wazte=-
Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
Wow ok so why would any one want to use this program i mean like is it fun just trying to geuss random numbers in a line?

And thanks for the info Toxic.

Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
its just practicing, u think i am going to write a OOP the firt time i try C++ ? Its a usless program but i learned a lot from it.


Good artists copy, great artists
steal.

-Picasso
Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
ok i got it thanx for splainin it.

Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
I have looked on the web all day and i cant find a free downloadable copy of this c++ program thingy bobber...were did u get yours?
(and did u acctually pay?)

Joined: Nov 2002
Posts: 1,146
Likes: 1
Ice Offline OP
UGN News Staff
OP Offline
UGN News Staff
Joined: Nov 2002
Posts: 1,146
Likes: 1
Its a Porgraming Language...


Good artists copy, great artists
steal.

-Picasso
Joined: Mar 2002
Posts: 599
UGN's Resident Homo
Offline
UGN's Resident Homo
Joined: Mar 2002
Posts: 599
coleman, c++ is a programming language, that means it is used to create other programs. the program ice created has no practical use other than to learn how to program in c++. as for getting c++ go here http://www.borland.com/products/downloads/download_cbuilder.html# click to download the compiler. i believe it is free.


"It's better to burn out, than to fade away."
Joined: Sep 2003
Posts: 36
Junior Member
Offline
Junior Member
Joined: Sep 2003
Posts: 36
ok thanx backslash i appretiate ur help and patients.

Joined: Oct 2003
Posts: 4
Junior Member
Offline
Junior Member
Joined: Oct 2003
Posts: 4
I think that you can use the key-words 'switch' instead of 'if-else'.

Joined: Dec 2003
Posts: 38
Junior Member
Offline
Junior Member
Joined: Dec 2003
Posts: 38
Quote:

oh, i just read your other program. Thats not how you stop it so you can see it, you are just wasting memory (not like its a lot but hey, its better you dont get used to it now that you are startin to learn).
#include "conio.h"
getch(); //that will pause till you press a key
wouldn't including stdlib.h and using system("pause"); be a little less coding. You could even define it as something like:
Code
#define PAUSE system("pause")
and then go to use it like this:
Code
main()
{
PAUSE;
}
and it would come out like this:
"Press any key..."
or similar message

Joined: Aug 2003
Posts: 240
Member
Offline
Member
Joined: Aug 2003
Posts: 240
very unoptomized code would be slow as hell.. but you will learn you taken the 1st step thats what counts so stop criticizing him :p


The wise make mistakes, the fools repeat them
----------------------------------------
When you have eliminated the impossible, that which remains, however improbable, must be the truth
Joined: Aug 2002
Posts: 68
S
Junior Member
Offline
Junior Member
S
Joined: Aug 2002
Posts: 68
C++ is fun. I suggest you get this book:

http://www.amazon.com/exec/obidos/t...162557?v=glance&s=books&n=507846

Very good. very good stuff indeed.

That and read some online tutorials. Write some neat code, have some cool fun. Oh, pergesu has good stuff to (find his profile, he's got links in it) and uhm uhm uhm other than that check out www.allegro.cc when you want to do low-level graphics programming.

And learn java too.

Joined: Dec 2003
Posts: 17
Junior Member
Offline
Junior Member
Joined: Dec 2003
Posts: 17
Coleman, if you don't know what you'll be able to do by being able to program C/C++, it's likely that there isn't much point in you learning it. If you'd just like to play around on the web, I suggest learning the basics first. Start with XHTML and PHP.

Joined: Feb 2004
Posts: 5
S
Junior Member
Offline
Junior Member
S
Joined: Feb 2004
Posts: 5
It's a example.Perhaps this example teaches the reader the application of the key word"if... else if...else". I think so.

Joined: Oct 2003
Posts: 209
Member
Offline
Member
Joined: Oct 2003
Posts: 209
Coleman: get to Dev C++ It's good smile

Ice: use something like this.. {variable = rand() % max;}
It'll give you a random number between 0 & "max"(which should also be replaced). I don't really know much about how it works, since I don't actually program in C++ :-D


Those who say do not know.
Those who know do not say.
Joined: Jan 2004
Posts: 6
V
Junior Member
Offline
Junior Member
V
Joined: Jan 2004
Posts: 6
variable = rand() % max;

rand() produces a random integer value.
% is called the modulus operator. It's basically what you learned to be the remainder in division. Ie. 5 % 3 = 2 and 16 % 5 = 1
As for this function, it actually only returns a number from 0 to max - 1, as you can't divide a number by a number and have the remainder equal to the divisor. Ie. a % b cannot equal b.


Link Copied to Clipboard
Member Spotlight
Posts: 30
Joined: June 2002
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Crime 1
Ice 1
Dartur 1
Cyrez 1
Powered by UBB.threads™ PHP Forum Software 7.7.5