Hi. I am a beginner of programming course and i just got anexercise problem.. an
ID: 3617829 • Letter: H
Question
Hi. I am a beginner of programming course and i just got anexercise problem.. and need your help.. Here's a question.. Write an algorithm that receives an n x n table(2 dimensionalarray havin n rows and n columns) of real values and returns average of the values on its upper left to lowerright diagonal. I would greatly appreciate your help.... Hi. I am a beginner of programming course and i just got anexercise problem.. and need your help.. Here's a question.. Write an algorithm that receives an n x n table(2 dimensionalarray havin n rows and n columns) of real values and returns average of the values on its upper left to lowerright diagonal. I would greatly appreciate your help....Explanation / Answer
double diagonalAvg(double[][] matrix, int n){ //Matrix is the 2D array and n isthe size of it. double avg = 0; int i, j; for(i = 0; i < size; i++){ avg += matrix[i][i]; } return (double)avg/size; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.