# randomize in c language

Page 1 of 1

## 1 Replies - 2550 Views - Last Post: 21 February 2010 - 05:07 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=157333&amp;s=02614661afc55acb0adced3bcd1c3575&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 lizzylynx

Reputation: 0
• Posts: 1
• Joined: 21-February 10

# randomize in c language

Posted 21 February 2010 - 03:23 AM

i dont know to use randomize in determining how many throws of dice that will result i a snake eye.
Is This A Good Question/Topic? 0

## Replies To: randomize in c language

### #2 DoubleFission

Reputation: 24
• Posts: 223
• Joined: 20-September 08

## Re: randomize in c language

Posted 21 February 2010 - 05:07 AM

You need to use the rand() function...

```// Write your generic program start parts here

srand(time(NULL)); // This 'seeds' the random number generator

// This is where you calculate how many times it takes... (Maybe a loop of some description)

// Randomly generate 2 numbers between 1-6

// Check if they are both 1, if so you have snake eyes...

```

The way you get random numbers between 2 specified values is:

rand() % <Range of possible values> + <Min number>

in this case the range is 6: 1, 2, 3, 4, 5, 6
and the minimum number is 1....

Hope that gives you all the understanding of how rand() works