how to generate random number [closed]

I want to generate a few random numbers in the range 0-999 and store them in an array. This is my code:

void randnum(int number)
{
    int i;
    int num;
    int arr[11];
    printf("%d", number);
    for (i = 0; i < number; i++) 
    {
        num = rand() % 999;
        arr[i]=num;
    }       
    for(i=0;i<number;i++)
        printf("%d \n", arr[i]);
    
}

The output is:

6478 664 153 268 500 997

Am I doing it right? Why does my output have number 6478 which is not in the 0-999 range?


printf("%d", number);

This will output number('6') but there is no newline after it. Try removing this line or change it to

printf("%d\n", number);