Question: (5 marks) Problem 1. Write a fiunction DiagonalMax that calculates and prints the maximum of the diagonal values of the two-dimensional array A. For simplicity,
(5 marks) Problem 1. Write a fiunction DiagonalMax that calculates and prints the maximum of the diagonal values of the two-dimensional array A. For simplicity, assume the array is always square. And elements are positive integers. For example, for the array A shown below, Diagonal(A) should print a message "Maximum of diagonals is 25". A- 1 6 11 16 21 2 12 17 22 3 8 13 18 23 4 9 14 19 26 5 10 15 20 25 You may edit and reus the Ql driver from the mock exam, posted to the forums, to test this function. As you want to test DiagonalMax with arrays of square dimensions your tests cases can be: DiagonalMax(A) should print Maximum of diagonals is 10 DiagonalMax(A) should print Maximum of diagonals is 10 A (mod(A,2)0 5; DiagonalMax(A) should print Maximum of diagonals is5 A(length(A),length(A))-6; DiagonalMax(A) should print Mannum ofdiagonals is DiagonalMax A) should print Maximum of diagonals is 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
