# HELP ME! find maximum random number

Page 1 of 1

## 1 Replies - 2587 Views - Last Post: 01 July 2008 - 11:34 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=56380&amp;s=bd41f3e72609a70294fbf1e1633fa864&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 kornni

Reputation: 0
• Posts: 10
• Joined: 01-July 08

# HELP ME! find maximum random number

Posted 01 July 2008 - 11:30 AM

I want program
find maximum random number
(C language)
Is This A Good Question/Topic? 0

## Replies To: HELP ME! find maximum random number

### #2 captainhampton

• Jawsome++;

Reputation: 14
• Posts: 548
• Joined: 17-October 07

## Re: HELP ME! find maximum random number

Posted 01 July 2008 - 11:34 AM

I will get you started but you really should post something so that we know you at least gave this a shot. Here is what you need to do:
Use the rand() function as such:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main ()
{
int i;

/* initialize random seed: */
srand ( time(NULL) );

/* generate secret number: */
i = rand();
j = rand();

if ( i > j )
cout << i << is the biggest <<endl;
else
cout << j is the biggest <<endl;

return 0;
}

This is just between two random numbers, but you could create as many as you need with a simple loop