Hi
I'am having probelms generating ramdon numbers can someone please help I will very much appriciate if someone would write a samll program on it in that was i can learn by decomposing the code and learn it for my self.
Quote from: "Hassan"Hi
I'am having probelms generating ramdon numbers can someone please help I will very much appriciate if someone would write a samll program on it in that was i can learn by decomposing the code and learn it for my self.
I assume you mean by using the run time function rand()
for(int i = 0; i<16; i++)
{
printf("%d\n", rand());
}
Or you can use a modulo for limiting output to a specified range.
for(int i = 0; i<16; i++)
{
printf("%hhd\n", (char)(rand()%256));
}
One can also seed the pseudo-random number generator before using it.
srand(GetTickCount());
or
srand(1234);
John