Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Purpose of the program: Create a program that generates random numbers, sto re t

ID: 3688311 • Letter: P

Question

Purpose of the program: Create a program that generates random numbers, sto re them in a 10 X 10 array, and find the average for each row, column , as well as whole numbers. Section 1 Set a random number seed with 2 followed by the last 3 digits of your student ID. Section 2 Generate random numbers, each ranging fro m 0 to 9, and store them in a 10 X 10 array. Section 3 Calculate the average for each row, colum n and whole. Section 4 Show the result to the screen. Averages must show 2 digits below the decimal point. Can this please be in iostream for C++? .

Explanation / Answer

#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
    double wtotal=0;
    int size=3,n[size][size];
    srand(time(NULL));
    cout<<"Elements & their averages ";
    for(int i=0;i<size;i++)
    {
        double total=0;
        for(int j=0;j<size;j++)
        {
            n[i][j]=rand()%9+1;
            total+=n[i][j];
            cout<<" "<<n[i][j];
            wtotal+=n[i][j];
        }
         cout<< " "<<setprecision(2)<<total/size<<" ";
    }
    int j=0;
    while(j<size)
    {
        double total=0;
        for(int i=0;i<size;i++)
        {
            total+=n[i][j];
        }
        cout<<setprecision(2)<<total/size;
        j++;
    }
    cout<<setprecision(2)<<(wtotal/(size*size));
    cout<<" ";
    return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote