# Fill array with random numbers c++

Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. Then modify it to also count and display the number of values between 1 and 25, 26 and 50, 51 and 75 and 76 to 100. Provide: 1. Snapshot of program run showing results for values 1 to 50 and 51 to 100.
2. Snapshot of program run showing results for values 1 to 25, 26 to 50, 51 to 75 and 76 to 100.       Copyable Code: #include <iostream> #include<cstdlib> #include<ctime> using namespace std; //main int main () { //initialization of variables float arr; int count=0; srand(time(NULL)); //loop to assign values into array for(int j=0;j<1000;j++) { arr[j]=(float(rand()%100))+1; } //random numbers between 1 and 50 cout<<“n Random numbers between 1 and 50:”; for(int j=0;j<1000;j++) { if(arr[j]>=1 && arr[j]<=50) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value between 1 and 50:”<<count; cout<<“n———————————————————“; //random numbers greater than 50 cout<<“n Random numbers greater than 50:”; count=0; for(int j=0;j<1000;j++) { if(arr[j]>50) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value greater than 50:”<<count; cout<<“n———————————————————“; ////random numbers between 1 and 25 cout<<“n Random numbers between 1 and 25:”; count=0; for(int j=0;j<1000;j++) { if(arr[j]>=1 && arr[j]<=25) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value between 1 and 25:”<<count; cout<<“n———————————————————“; //random numbers between 26 and 50 cout<<“n Random numbers between 26 and 50:”; count=0; for(int j=0;j<1000;j++) { if(arr[j]>=26 && arr[j]<=50) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value between 26 and 50:”<<count; cout<<“n———————————————-“; //random numbers between 51 and 75 cout<<“n Random numbers between 51 and 75:”; count=0; for(int j=0;j<1000;j++) { if(arr[j]>=51 && arr[j]<=75) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value between 51 and 75:”<<count; cout<<“n———————————————————“; //random numbers between 76 and 100 cout<<“n Random numbers between 76 and 100:”; count=0; for(int j=0;j<1000;j++) { if(arr[j]>=76 && arr[j]<=100) { cout<<arr[j]<<“t”; count=count+1; } } cout<<“nNumber of random value between 76 and 100:”<<count; cout<<“n———————————————————“; return 0; }