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, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
Sponsored Links
Latest Postings
by Herbert_Sherbert
09/07/15 10:34 AM
Latest Reviews
Topic Options
Rate This Topic
#17223 - 06/02/05 02: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?

Sponsored Links
#17224 - 06/02/05 07:17 AM Re: Guess the number game?
Digital Geek Offline
UGN Super Poster

Registered: 09/18/02
Posts: 553
Loc: Cluj-Napoca, Romania
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

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

        int random_number;
        srand( (unsigned)time( NULL ) ); /*making sure we don't use the same seed and getting the same sequence of random numbers*/
        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.

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

Registered: 09/18/02
Posts: 553
Loc: Cluj-Napoca, Romania
Forgot to close the main begin there, so put: "}" in the last line of the program.

#17226 - 08/06/05 10:46 AM 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!

#17227 - 02/08/06 10:54 PM Re: Guess the number game?
munin_dk_cn Offline
Junior Member

Registered: 02/08/06
Posts: 3
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]


Featured Member
Registered: 09/07/15
Posts: 1
Forum Stats
2158 Members
46 Forums
41462 Topics
76636 Posts

Max Online: 1567 @ 04/25/10 02:20 AM
Top Posters
UGN Security 34624
Gremelin 7193
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
Herbert_Sherbert, codemauve, Lillysdragon1984, Brewwit, Suri John
2157 Registered Users
Who's Online
0 registered (), 277 Guests and 175 Spiders online.
Key: Admin, Global Mod, Mod
Latest News

  Get Firefox!
Get FireFox!