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.

## Answer

**Copyable Code:**#include <iostream> #include<cstdlib> #include<ctime> using namespace std; //main int main () { //initialization of variables float arr[1000]; 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; }

We were unable to transcribe this image

if (arr[5]>50) coutくくarr [] ]<4″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](525) 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 [] ]<4″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:”

We were unable to transcribe this image

We were unable to transcribe this image

י CAUsersiR.AN tsVisual Studio 20081ProjectslexpDebuglexp.exe Random numbers greater than 5093 84 80 87 87 100 70 72 78 72 74 64 78 74 72 60 74 78 79 80 80 78 78 72 79 80 72 84 64 70 76 87 80 70 80 72 64 74 64 72 75 64 76 73 64 70 76 76 60 70 78 90 87 72 84 87 80 60 90 74 87 90 72 72 74 60 78 100 76 90 72 64 87 60 87 90 100 76 76 72 70 78 79 60 72 87 60 74 76 74 87 75 64 70 90 80 87 80 79 70 80 90 80 76 79 90 84 100 74 87 87 100 80 80 60 87 70 72 72 84 Number of random value greater than 50 505 79 90 76 72 80 76 72 79 60 90 75 94

Random numbers between 1 and 25:2 24 24 24 24 24 20 24 4 24 4 4 20 40 45 40 Number of random value between 1 and 25:256 48 48 48 Random numbers between 26 and 50:34 49 46 42 48 47 45 49 49 42 43 43 47 45 45 48 48 46 45 47 47 40 48 45 47 43 43 47 47 43 40 48 42 43 45 43 42 43 40 48 45 49 40 43 45 45 47 42 46 42 43 48 42 45 48 43 43 48 47 43 45 45 45 45 42 46 49 45 42 43 48 49 42 40 40 45 49 47 Number of random value between 26 and 50:239

Random numbers between 51 and 75:67 70 73 72 74 72 64 74 73 74 73 74 72 70 72 70 72 72 73 60 73 70 70 73 74 73 74 72 64 70 74 74 72 64 70 73 70 73 4 70 72 72 72 73 73 72 73 Number of random value between 51 and 75:265 Random numbers between76 and 100:93 88 84 79 80 87 100 87 78 79 72 72 78 79 78 78 80 78 80 90 80 80 80 84 87 87 87 84 90 72 90 78 90 72 80 87 72 94 78 100 90 87 79 87 100 90 72 78 87 87 80 80 87 90 100 80 87 80 90 76 79 84 79 80 80 87 100 79 87 90 84 80 72 76 79 94 76 76 Number of random value between76 and 100:240 Press any key to con