I am trying to right a program, with arrays, which gets random numbers between 0 - 24 but they can only occur once. I know how to generate random numbers, I am just stuck on how to do the check to see if the number already exists in the array. I tried generating a new rand() % 25 and comparing it with placeholders in the array and if it didn't exist put the new random number in there but it did not work.
void MultiU (){
int size = 5;
int array[5];
srand(time(0));
for (int index = 0; index < size; index++){
exists[index] = rand() %25;
}
}
I am new to programming with arrays and rand(). I hope someone can guide me in the right direction.