Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


8,120 questions

11,301 answers

573 users

How to fill an array with random numbers in C

1 Answer

0 votes
#include <stdio.h>     
#include <time.h> 
#include <stdlib.h> 

#define N 15

int main(void)
{
    int arr[N];
 
    srand((unsigned int)time(NULL));
 
    for (int i = 0; i < N; i++)
        arr[i] = (rand() % 1000);
 
    for (int i = 0; i < N; i++)
        printf("%d\n", arr[i]);
    
    return 0;
}

/*
run:

16
541
639
960
650
424
470
66
634
176
259
531
378
884
51

*/

 




answered May 14 by avibootz
...