I have to produce a random number and can't figure it out. It gives me the same number each time. This isn't the homework. She told us how to produce the random number and i can't figure it out. The program I am writing for class is to learn how to use if statements.

I'm supposed to call srand once with a large prime number: srand(2707). Then it goes on to say that when you call srand with time as seed: srand(time(NULL)) the seed and the number will be different each time you run the program.

Here is the code that I have:

#include <iostream.h>

#include <iomanip.h>

#include <fstream.h>

#include <stdlib.h>

#include <time.h>

// I was told to include these three, should MAX_NUMBER be float?

void srand( unsigned int seed );

int rand ( void );

const float MAX_NUMBER = 20.0;

//

int main()

{

int number;

srand ( time( NULL ));

//I was also told to include this one.

number = int((float(rand() ) / float( RAND_MAX )) * MAX_NUMBER );

//

cout << number << endl;

system("PAUSE");

return 0;

}