I have a program that reads random numbers into an array. I am trying to get rid of the duplicates that are sometimes generated. Do I need to use a sort or another loop. Anyone...please.
(PS. Jazz. You gave me 4 functions for this quite a while ago, but being the slow poke that I am, I can't figure out how to use the code without functions here!) TIA
main()
{
int array[20];//create an array with 20 elements
int i; //index counter
srand(time(NULL)); //set random
for (i = 0; i < 20; i++) //fill the array
{
array[i] = 1+ rand() % 89; //fill each element of the array with a random number
}//end for
//output
for (i = 0; i < 20; i++)
{
printf("%2d\n", array[i]); //print the array element values
}//end for
}//end function main