Your browser does not seem to support CSS. If images appear below, please disregard them.
It appears that you're running an Ad-Blocker. This site is monetized by Advertising and by ">User Donations; we ask that if you find this site helpful that you whitelist us in your Ad-Blocker, or make a ">Donation to help aid in operating costs.
Previous Thread
Next Thread
Print Thread
Rate This Thread
#17223 - 06/02/05 09:47 AM Guess the number game?  
Joined: Jun 2005
Posts: 3
Gothy Offline
Junior Member
Gothy  Offline
Junior Member

Joined: Jun 2005
Posts: 3
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 02:17 PM Re: Guess the number game?  
Joined: Sep 2002
Posts: 553
Digital Geek Offline
UGN Super Poster
Digital Geek  Offline
UGN Super Poster

Joined: Sep 2002
Posts: 553
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

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.

#17225 - 06/02/05 06:25 PM Re: Guess the number game?  
Joined: Sep 2002
Posts: 553
Digital Geek Offline
UGN Super Poster
Digital Geek  Offline
UGN Super Poster

Joined: Sep 2002
Posts: 553
Cluj-Napoca, Romania
Forgot to close the main begin there, so put: "}" in the last line of the program.

#17226 - 08/06/05 05:46 PM Re: Guess the number game?  
Joined: Jan 2005
Posts: 589
EndGame Offline
UGN Custodian
EndGame  Offline
UGN Custodian

Joined: Jan 2005
Posts: 589
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/09/06 06:54 AM Re: Guess the number game?  
Joined: Feb 2006
Posts: 3
munin_dk_cn Offline
Junior Member
munin_dk_cn  Offline
Junior Member

Joined: Feb 2006
Posts: 3
CHINA
A random number in 5-10 ,only need to do this(i think):

random_number=( 5+ rand()%6 );


what you are you do not see, what you see is your shadow.
Sponsored Links

Member Spotlight
mtlhd
mtlhd
Los Angeles,CA
Posts: 70
Joined: May 2002
Show All Member Profiles 
Forum Statistics
Forums41
Topics33,702
Posts68,797
Average Daily Posts0
Members2,172
Most Online1,567
Apr 25th, 2010
Latest Postings
Okay WTF?
by HenryMiring on 09/27/17 08:45 AM
The History Thread...
by Gremelin on 08/11/17 07:11 PM
my old account still exists!
by Gremelin on 08/11/17 07:02 PM
My friend NEEDS your HELP!
by Lena01 on 07/21/17 07:06 AM
I'm having fun with this guy.
by gabithompson730 on 07/20/17 08:50 AM
I want to upgrade my phone
by gabithompson730 on 07/20/17 08:49 AM
Newbie here
by gabithompson730 on 07/20/17 08:46 AM
Blackbeard.....
by Gremelin on 01/14/17 07:03 PM
Top Posters(All Time)
UGN Security 41,392
Gremelin 7,202
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 3
Black Beard Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
fleshwound Likes: 1
Ghost Likes: 2
Gremelin Likes: 12
Ice Likes: 1
ninjaneo Likes: 1
Powered by UBB.threads™ PHP Forum Software 7.6.0
(Snapshot build 20170206)