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);
}
So I appreciate your help
Thanks.