Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ My output is wrong and don't know to fix it the code. #include using namespace std; const int Row = 50; const int Col

c++

My output is wrong and don't know to fix it the code.

#include

using namespace std;

const int Row = 50;

const int Col = 50;

int index = 1;

void getArray(int A[Row][Col], int row, int col);

void getTotal(int A[Row][Col], int row, int col, int &total);

void getAverage(int A[Row][Col], int row, int col, int total, int &average);

void getRowtotal(int A[Row][Col], int row, int col, int index, int &total);

void getColtotal(int A[Row][Col], int row, int col, int index, int &total);

void getHighestInRow(int A[Row][Col], int row, int col, int index, int &highestR);

void getHighestInCol(int A[Row][Col], int row, int col, int index, int &highestC);

void getLowestInRow(int A[Row][Col], int row, int col, int index, int &lowestR);

void getLowestInCol(int A[Row][Col], int row, int col, int index, int &lowestC);

void showArray(int A[Row][Col], int row, int col, int total, int average, int highestR, int highestC, int lowestR, int lowestC);

int main() {

int col, row, total, average, highestR, highestC, lowestR, lowestC;

int A[Row][Col];

cout << "Enter the rows: ";

cin >> row;

cout << "Enter the columns: ";

cin >> col;

getArray(A, row, col);

getTotal(A, row, col, total);

getAverage(A, row, col, total, average);

getRowtotal(A, row, col, index, total);

getColtotal(A, row, col, index, total);

getHighestInRow(A, row, col, index, highestR);

getHighestInCol(A, row, col, index, highestC);

getLowestInRow(A, row, col, index, lowestR);

getLowestInCol(A, row, col, index, lowestC);

showArray(A, row, col, total, average, highestR, highestC, lowestR, lowestC);

system("pause");

return 0;

}

void getArray(int A[Row][Col], int row, int col) {

int i, j;

for (i = 0; i < row; i++) {

for (j = 0; j < col; j++) {

cout << "A [" << i << "][" << j << "]";

cin >> A[i][j];

}

}

}

void getTotal(int A[Row][Col], int row, int col, int &total) {

int i, j;

total = 0;

for (i = 0; i < row; i++) {

for (j = 0; j < col; j++) {

total = total + A[i][j];

}

}

}

void getAverage(int A[Row][Col], int row, int col, int total, int &average) {

int i, j;

for (i = 0; i < row; i++) {

for (j = 0; j < col; j++) {

average = total / (row*col);

}

}

}

void getRowtotal(int A[Row][Col], int row, int col, int index, int &total) {

int i;

total = 0;

for (i = 0; i < col; i++) {

total += A[index][i];

}

}

void getColtotal(int A[Row][Col], int row, int col, int index, int &total) {

int i;

total = 0;

for (i = 0; i < row; i++) {

total += A[index][i];

}

}

void getHighestInRow(int A[Row][Col], int row, int col, int index, int &highestR) {

int i;

highestR = A[row][0];

for (i = 0; i < col; i++) {

if (A[index][i] > highestR) {

highestR = A[index][i];

}

}

}

void getHighestInCol(int A[Row][Col], int row, int col, int index, int &highestC) {

int i;

highestC = A[col][0];

for (i = 1; i < col; i++) {

if (A[index][i] > highestC) {

highestC = A[index][i];

}

}

}

void getLowestInRow(int A[Row][Col], int row, int col, int index, int &lowestR) {

int i;

lowestR = A[row][0];

for (i = 0; i < col; i++) {

if (A[index][i] < lowestR) {

lowestR = A[index][i];

}

}

}

void getLowestInCol(int A[Row][Col], int row, int col, int index, int &lowestC) {

int i;

lowestC = A[col][0];

for (i = 1; i < col; i++) {

if (A[index][i] < lowestC) {

lowestC = A[index][i];

}

}

}

void showArray(int A[Row][Col], int row, int col, int total, int average, int highestR, int highestC, int lowestR, int lowestC) {

int i, j;

for (i = 0; i < row; i++) {

for (j = 0; j < col; j++) {

cout << A[i][j] << " ";

}

}cout << endl;

cout << "The total is " << total << endl;

cout << "The average is " << average << endl;

cout << "The highest number is the row is: " << highestR << endl;

cout << "The highest number in the column is: " << highestC << endl;

cout << "The lowest number in the row is: " << lowestR << endl;

cout << "The lowest number in the column is: " << lowestC << endl;

}

/*

Enter the rows: 3

Enter the columns: 2

A [0][0]8

A [0][1]2

A [1][0]5

A [1][1]3

A [2][0]4

A [2][1]6

8 2 5 3 4 6

The total is -858993452

The average is 4

The highest number is the row is: 5

The highest number in the column is: 4

The lowest number in the row is: -858993460

The lowest number in the column is: 3

Press any key to continue . . .

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

=+Where does the focus of labor relations lie? Is it collective

Answered: 1 week ago

Question

=+With whom does the firm have to negotiate?

Answered: 1 week ago