I am trying to write a function that will fill an array with 100 random integers and everything I have tried so far fills the array with the same int. Here is my code:
int getrandom (int a2[ ])
{
int i;
srand(time(NULL));
for (i = 0; i %26lt; 100; i++)
a2[i]=rand();
return;
}
What is wrong with my C code?
int getrandom (int a2[ ])
{
int i;
int theRandom;
for (i = 0; i %26lt; 100; i++) {
theRandom = rand();
a2[i]=theRandom;
}
return;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment