HELP ME! find maximum random number

find maximum random number

Page 1 of 1

1 Replies - 2056 Views - Last Post: 01 July 2008 - 11:34 AM Rate Topic: -----

#1 kornni  Icon User is offline

  • New D.I.C Head

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

HELP ME! find maximum random number

Post icon  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  Icon User is offline

  • Jawsome++;
  • member icon

Reputation: 13
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1