# How do you calculate the arithmetic mean in each line of the matrix?

• Remembrance is required for the matrix dynamically and complete. random numbers, calculate the arithmetic mean in each line of the matrix. The memory has given it, filled it with random numbers, how to calculate the average arithmetic line, I can't figure it out.

``````#include <iostream>
#include <time.h>
#include <windows.h>
using namespace std;
int main(void)
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int N;
int M;
int  sum = 0;
cout &lt;&lt; "Введите количество строк матрицы: " &lt;&lt; endl;
cin &gt;&gt; N;

cout &lt;&lt; "Введите количество столбцов матрицы: " &lt;&lt; endl;
cin &gt;&gt; M;

/*_____________________________*/

int **arr = new int*[N];
for (int i = 0; i &lt; N; i++)
{
arr[i] = new int[M];
}

/*_____________________________*/

for (int i = 0; i &lt; N; i++)
{
for (int j = 0; j &lt; M; j++)
{
arr[i][j] = rand() % 20;
}
}

/*_____________________________*/

for (int i = 0; i &lt; N; i++)
{
for (int j = 0; j &lt; M; j++)
{
cout &lt;&lt; arr[i][j] &lt;&lt; "\t";
}
cout &lt;&lt; endl;
}

/*_____________________________*/

/*_____________________________*/

for (int i = 0; i &lt; N; i++)
{
delete[] arr[i];
}

delete[] arr;

return 0;

}
``````

• Mid-Arithmetic is the sum of all members divided by their col-vo. Therefore:

``````float averageRow;
for (int i = 0; i < N; i++)
{
averageRow = 0;
for (int j = 0; j < M; j++)
{
averageRow += arr[i][j];
}
averageRow /=M;
cout <<"Average row " << i <<": " << averageRow <<  endl;
}
``````

2

2

2

2

2

2

2

2

2

2

2

2

2

2

2