Can we make an array and read the randomly generated values one by one into the array using a for loop ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can we make an array and read the randomly generated values one by one into the array using a for loop ??

27th Dec 2015, 2:09 PM
Abhishek Raj
Abhishek Raj - avatar
1 Answer
+ 3
you can load your array with random numbers this way: for (int i=0; i < sizeOfArray; i++) array_name [i]=rand (); but remember to include <ctime> and srand (time (0)) at the beginning so that rand () generates different numbers
16th Jan 2016, 2:04 PM
Sardor
Sardor - avatar