UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
December
Su M Tu W Th F Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Our Sponsors


Latest Postings
My friend NEEDS your HELP!
by Gizmo
11/26/08 12:21 AM
Useful PHP Functions & Code
by Gizmo
11/13/08 09:25 PM
UBBCode Tags
by Gizmo
11/13/08 09:25 PM
Topic Options
Rate This Topic
#17223 - 06/02/05 05:47 AM Guess the number game?
Gothy Offline
Junior Member

Registered: 06/02/05
Posts: 3
Loc: New Jersey
ok so i've worked at this a billion times and I still dont get it *BAH*. I used a random number generator then an if statement, so if the the generator hit a certain # between like 5-10 then it would say heads. I know get what im saying here, so is anyone willing to help a newb out?

Top
Our Sponsors
Sponsor Our Sponsors

Sponsor Advertisements help keep UGN Security Online.



Support UGN Security by Purchasing our Sponsors Products.
Top  
#17224 - 06/02/05 10:17 AM Re: Guess the number game?
Digital Geek Offline
UGN Super Poster

Registered: 09/18/02
Posts: 522
Loc: Madrid, Spain
Well lots of people are willing to help if you'll and post your question right and be more specific.

Anyway, form what I understand you want to generate random numbers untill you find one between 5 and 10 and then dispaly a message heads and exit the program

Code:
#include <stdio.h>
#include <stdlib.h>

main()
{
        int random_number;
        srand( (unsigned)time( NULL ) ); /*making sure we don't use the same seed and getting the same sequence of random numbers*/
        do
        {
        random_number=(rand()%21); /*generates a number between 0 and 20*/
        } while ((random_number<=5) &#0124;&#0124; (random_number>=10)); /*we generate numbers until we generate one between 5 and 10*/

        printf("Heads ! (%d)", random_number); /*when we exit the while loop our number is between 5 and 10 so we can print Heads and the number generated*/
To compile under linux use : gcc random.c -o random

Hope this helps you.

Top
#17225 - 06/02/05 02:25 PM Re: Guess the number game?
Digital Geek Offline
UGN Super Poster

Registered: 09/18/02
Posts: 522
Loc: Madrid, Spain
Forgot to close the main begin there, so put: "}" in the last line of the program.

Top
#17226 - 08/06/05 01:46 PM Re: Guess the number game?
EndGame Offline
UGN Custodian

Registered: 01/23/05
Posts: 589
Loc: brisbane (or any local pub)
i think u just did his homework for him DG :p
_________________________
Harry Potter Thread
if ur bored on the boards, get posting THERE!

Top
#17227 - 02/09/06 01:54 AM Re: Guess the number game?
munin_dk_cn Offline
Junior Member

Registered: 02/08/06
Posts: 3
Loc: CHINA
A random number in 5-10 ,only need to do this(i think):

random_number=( 5+ rand()%6 );
_________________________
[color=#C10019]what you are you do not see, what you see is your shadow.[/color]

Top



Featured Member
Registered: 03/03/02
Posts: 23
Forum Stats
6889 Members
44 Forums
11030 Topics
45809 Posts

Max Online: 677 @ 06/30/07 10:06 PM
Top Posters
Gizmo 6958
UGN Security 4080
§intå× 3252
IceMyst 1449
SilentRage 1273
Ice 1146
pergesu 1134
Infinite 1039
jonconley 954
Girlie 903
Newest Members
lucky vin, prEttyNDistress, AndrewKlilly, border, f4k3m3
6889 Registered Users
Who's Online
0 registered (), 6 Guests and 7 Spiders online.
Key: Admin, Global Mod, Mod
Latest News
Update Humpday - Sept 26, 2008
by Gizmo
11/28/08 03:39 AM
Happy Holidays!
by Gizmo
11/27/08 09:09 AM
New Mailing
by Gizmo
11/24/08 01:30 PM
A special update...
by Gizmo
11/24/08 01:10 PM
Required Reading Update...
by Gizmo
11/07/08 11:36 AM


Donate
  Get Firefox!
Get FireFox!