# Thread: Need Help software is not exactly performs the required

1. ## Need Help software is not exactly performs the required

Hello friends I need your help.
My program is such an array size in 1000 where the numbers should be between 0-999. These numbers should be determined randomly (rand loop) and the number must not be repeated. Would be considered the main part, I have to count how many times I used rand ().

My idea is that one loop where it initializes all the 1000 numbers, and another loop to check whether the number appears twice, if the number appears twice is set it again until that not appear twice (maybe this is not the best way but ...)

It is my exercise (Here I need your help)-

Code:
```#include <stdio.h>#include <stdlib.h>

int main()
{
int i, j;
int arr[1000];
int loop = 0;

for (i = 0; i<10000; i++)
{
arr[i] = rand() % 1000;
loop++;
}

for (j = 0; j<10000; j++)
{
if(arr[j] == arr[j + 1])
{
arr[i] = rand() % 1000;
loop++;
}
}

printf("%d\n",loop);
}
```
Thanks.

2. > int arr[1000];
> for (i = 0; i<10000; i++)
Your first problem is massive array overruns.

Before you start writing code, check your algorithm for finding duplicates on paper with a small array, such as

1 2 4 1 5

Do you think " if(arr[j] == arr[j + 1]) " is going to find the 2nd duplicate 1 in this array?

If you want a better approach, consider filling the array with unique numbers using a for loop, then shuffle it.

3. Just populate your array with 1000 (not 10000, as pointed out by Salem) distinct values and then randomly shuffle.