In: Computer Science
c++
I need a code that will fill an array size of 1000, an array of size 2000, and an array size of 10000, with random int values.
Basically like this:
array1[1000] = filled all with random numbers
array2[2000] = filled all with random numbers
array3[10000] = filled all with random numbers
C++
no need for print
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
int array1[1000];
int array2[2000];
int array3[10000];
int i;
srand((unsigned) time(0)); // every time new random
numbers are generated.
for(i=0;i<1000;i++) // array1 filled all with
random numbers
array1[i] = rand();
for(i=0;i<2000;i++) // array2 filled all with
random numbers
array2[i] = rand();
for(i=0;i<10000;i++) // array3 filled all with
random numbers
array3[i] = rand();
return 0;
}
Screenshot of the program
NOTE: If you want to change something , please let me know through comments; I will surely revert back to you.
Please give a up vote .....
Thank you...