Programming Homework Help

QCC Make Int Array Numbers with Size 1000 in Main Function Programming

 

I’m working on a c++ project and need guidance to help me understand better.

  1. Make int array numbers with size 1000 in main function.
  2. Assign 1000 int random numbers beteen 1 and 100 to numbers in main function.Use c++11 random library instead of rand in cstdlib. ( Use std::random_device,std::mt19937, std::uniform_int_distribution<int>).
  3. Make int array ftable with size 5 in main function,
  4. count 1000 random numbers in numbers in main function. For each x in numbers,If 1<=x<=20, increase ftable[0] by 1. If 21<x<=40, increase ftable[1] by 1. If 41<x<=60, increase ftable[2] by 1. If 61<x<=80, increase ftable[3] by 1. If 81<x<=100, increase ftable[4] by 1.

page1image47740224

5. make void show_ftable(int ftable[], int n) which prints the result of ftable with size n. Of course, in this case, n=5. If we call show_ftable(ftable,5); then it may show this screenshot depending of ftable.

 [1,20]:207
 [21,40]:197
 [41,60]:204
 [61,80]:197
 [81,100]:195

6. Make double avg(int numbers[],int n) which returns the average of an array numbers with size n. (For this project, n=1000)

Screenshots
Since you use random numbers, the screenshot may be different.

Frequency table [1,20]:221 [21,40]:207 [41,60]:176 [61,80]:209 [81,100]:187 avg=49.068

Frequency table [1,20]:205 [21,40]:190 [41,60]:208 [61,80]:207 [81,100]:190 avg=50.369

Frequency table [1,20]:216 [21,40]:185 [41,60]:184 [61,80]:198 [81,100]:217 avg=51.018

Can you please put the code under this guideline. I am a little bit confused.Thanks.

#include<iostream>

using namespace std;

#include <random>

#include <iostream>

using namespace std;

void show_ftable(int ftable[], int n);

double avg(int numbers[],int n);

int main(){

// write your code below

cout<<“Frequency table”<<endl;

show_ftable(ftable,5);

cout<<“avg=”<<avg(numbers,1000)<<endl;

return 0;

}

// define show_ftable and avg function below.