Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, the main code passes to the CheckMatrix function a 2-dimensional array of integer numbers. First, the CheckMatrix function checks if the array

In this exercise, the main code passes to the CheckMatrix function a 2-dimensional array of integer numbers.

First, the CheckMatrix function checks if the array represents a square matrix (i.e. number of rows equals number of columns). If the array is not square, the function prints "NONE" and exits.

Second, if the array is square, the function checks if it is diagonal or not. A square matrix is diagonal when all elements other than the diagonal elements are zero. For example, the following matrix is a 3x3 diagonal matrix:

3 0 0

0 2 0

0 0 -4

If the array is diagonal, the function prints 1, otherwise it prints 0.

Third, the function checks if the array is scalar or not. A scalar matrix is a diagonal matrix with equivalent diagonal elements. For example, the following matrix is a 3x3 scalar matrix:

2 0 0

0 2 0

0 0 2

If the array is scalar, the function prints 1, otherwise it prints 0.

Lastly, the function checks if the array is identity or not. An identity matrix is a scalar matrix with all diagonal elements equal to 1. For example, the following matrix is a 3x3 identity matrix:

1 0 0

0 1 0

0 0 1

If the array is scalar, the function prints 1, otherwise it prints 0.

You are required to write the body for the function called CheckMatrix. Your code should work with any COLUMN_SIZE integer value that is greater than 1.

void CheckMatrix (int m[][COLUMN_SIZE], int ROW_SIZE) {

}

not graded, for student use only):

Input:

Suppose main calls CheckMatrix as CheckMatrix(m[][3], 2) with m equals:

5 0 0

0 5 0

Function Output:

NONE

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

The random variable Y can take on any value from to +. LO.1

Answered: 1 week ago