randomize how to use?

This is a discussion on randomize how to use? within the C++ Programming forums, part of the General Programming Boards category; i m want to learn c++
i have a problem
i dont know how to use rand()
can u help ...

randomize how to use?

randomize() is one of the functions that will seed a random number generator, like rand(). You should use randomize() just once in your program, but you may use rand() as often as you wish. To generate a random integer you would do this:

2) the functions you need are srand() to seed the random number generator and rand() to give you a random number between 0 and RAND_MAX.You will find these functions in <cstdlib> or <stdlib.h>

so...

Code:

#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
// seed the random num gen. with system time for unique randomness
srand((unsigned)time(NULL));
// now a loop
for(int i=0;i<10;i++)
{
//get a random number between 1 and 100.
//we use modulus to get a number in the desired range.
//+1 because %100 returns 0-99
int randomnum=rand() %100 +1;
cout<<randomnum<<endl;
}
return 0;
}