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: 3687827 • 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.

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>

int main()
{
    double wtotal=0;
    int size=3,n[size][size];
    srand(time(NULL));
    printf("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];
            printf("%d ",n[i][j]);
            wtotal+=n[i][j];
        }
         printf("%2.2f ",total/size);
    }
    int j=0;
    while(j<size)
    {
        double total=0;
        for(int i=0;i<size;i++)
        {
            total+=n[i][j];
        }
        printf("%2.2f ",total/size);
        j++;
    }
    printf("%2.2f",(wtotal/(size*size)));
    printf(" ");
    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