Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is the code #include #define MAX_SIZE 20 // function definitions int isUpperTriangular(int matrix[][MAX_SIZE], int size); int isLowerTriangular(int matrix[][MAX_SIZE], int size); int isDiagonal(int matrix[][MAX_SIZE], int
Here is the code
#include#define MAX_SIZE 20 // function definitions int isUpperTriangular(int matrix[][MAX_SIZE], int size); int isLowerTriangular(int matrix[][MAX_SIZE], int size); int isDiagonal(int matrix[][MAX_SIZE], int size); int takeInput(int inputMatrix[][MAX_SIZE]); int main() { int matrix[MAX_SIZE][MAX_SIZE]; int matrixSize = takeInput(matrix); if (isDiagonal(matrix, matrixSize)) { printf("The matrix is diagonal. "); } else { printf("The matrix is NOT diagonal. "); } if (isUpperTriangular(matrix, matrixSize)) { printf("The matrix is upper triangular. "); } else { printf("The matrix is NOT upper triangular. "); } if (isLowerTriangular(matrix, matrixSize)) { printf("The matrix is lower triangular. "); } else { printf("The matrix is NOT lower triangular. "); } } // already implemented for you int takeInput(int inputMatrix[][MAX_SIZE]) { int size; printf("What is the size of your matrix? "); fflush(stdout); scanf("%d", &size); int i; for (i = 0; i 1) Matrix Problem: For this problem, you are going to implement three functions called isDiagonal, isUpperTriangular and isLowerTriangular which determine whether the matrix (passed to the function as a parameter) is diagonal, upper triangular and/or lower-triangular. The matrix is diagonal, if all the cells other than [i][i] are zero (in other words cell[i][j] = 0 if i !:). The matrix is upper triangular if all the cells [i] is 0, if i >j. The matrix is lower triangular, if all the cells [] is O if Function headers must be: o isUpperTriangular(int matrixD[MAX_SIZE], int size); o isLowerTriangular(int matrixD[MAX_SIZE], int size); o isDiagonal(int matrixD[MAX_SIZE], int size); [Assumption] The matrix passed to these function are square matrix [Assumption] The maximum size of the matrices is 20 by 20 (as . The main program MUST be as follows (and MUST NOT be changed at (ie, number of rows of the matrix = number of columns of the matrix) MAX_SIZE is defined 20 by 20 in the program) all) #include #define MAX-SIZE 20 function definitions int isupperTriangular(int matrix[MAX SIZE], int size): int isLowerTriangular(int matrix[](MAX_SIZE], int size); int isDiagonal(int matrix[[MAX_SIZE, int size) int takeInput(int inputMatrix[(MAX SIZE): int main) t int matrix(MAXSIZE)[MAX_SIZE] int matrixsize takeInput (matrix) if (isDiagonal(matrix, matrixsize) 1 else t printf( The natrix is diagonal. ") printf( The natrix is NOT diagonal. "): if (isUpperTriangular(matrix, matrixsize)) printf(The natrix is upper triangular.n") else ( printf( The matrix is NOT upper triangular. n" if (isLowerTriangular(matrix, matrixsize)) printf( The matrix is lower triangular. "): else t printf("The natrix is NOT lower triangular. ") already implemented for you int takeinput(int inputMatrixtI[MAX SIZE]) D TO BE COMPLETED BY YOU int isUpperTriangular(int matrix[]MAX_SIZE], int size) int isLowerTriangular(int matrix[[MAX SIZE] int size) int isDiagonal(int matrixI[MAX SIZE], int size)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started