Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need a quick c++ code for this question please In this exercise, the main code passes to the CheckMatrix function a 2-dimensional array of

i need a quick c++ code for this question please
image text in transcribed
image text in transcribed

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.

IMPORTANT NOTE
  • Do not write and submit the main subroutine, or any include statments, these are already written and hidden from you. However, if you want to test your solution in any IDE (e.g., CodeBlocks, CLion, Visual Studio, onlinegdb.com), then you will need to write your own main there for testing purposes.
  • In the function header, do not change the order of the formal paramaters or add/remove others parameters.
  • Do not change the function name.
  • Do not change the name of the constant COLUMN_SIZE.
  • Do not add any cout statements except for the final answer as specified above.
  • Do not add "Enter row size", "the matrix is" or any similar prompts.
Sample Testcase 0 (not graded, for student use only):

Input:

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

5 0 0

0 5 0

0 0 5

Function Output:

1

1

0

Sample Testcase 1 (not graded, for student use only):

Input:

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

5 0 0

0 5 0

0 0 1

Function Output:

1

0

0

Sample Testcase 2 (not graded, for student use only):

Input:

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

1 4 0

0 1 0

9 0 1

Function Output:

0

0

0

Sample Testcase 3 (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

1
void CheckMatrix (int m[][COLUMN_SIZE], int ROW_SIZE)
2
{
3
4
5
6
7
8
}

HW3-F Diagonal Matrices Collagen (Chapter 8) In this exerce, the main cade passes to the Checklatrix tunction a 2 dimensional array of integer numbers First, the CheckMate function check if the array represents a square matrix De number of rows equals number of column the array is not square the function prints "NONE" and exits. Second if the array is square the function chedis if it is diagonal or not. A square matrixis diagonal when all elements other than the diagonal elements are zero. For example, the following matro diagonal matrie 300 020 00+ if the array is diaporat the function protherwise itprints Third, the function checks of the array is cor not. A scator matricia diagonal matrix with equivalent diagonal elements. For example, the following matrix is a 33 scalar matre 200 020 002 if the array is scalar, the function prints therwise itprints 0. Lastly, the function ched if the array is identity or not. An entity matrix scalar matrix with all diagonal elements equal to 1 For example the following matras in a centry raarties 100 010 001 if the array is scalar, the function prins cherwise itprints You are required to write the body for the function clied Check Metre Your code should work with any COLUMN SIZE Integer value that is greater than 1 IMPORTANT NOTE Do not write and submit the man sabroutine or any include statments, these are already written and hidden from you. However, if you want to test your solution in any Oles. Code locks. Chion Visual Studienet.com, then you will need to write your own main there for testing purposes. - In the function header, do not change the order of the format paraaters or add remove others parameters . Do not change the function name . Do not change the name of the constant COLUMN SIZE Do not add any cout statements except for the final answer as specified above . Do not add "Enter row them or any prompts Input Supposema als Chedi Matras Check with quals 500 OSO 001 Function Output O Sample Testcase 2 more for student use only Input Suppone man als CheckMatris Che Mat OL with 140 010 903 Function Output 0 D 0 Sample Testcase inot gadied for det sel Input: Suppose man als Cheats Cheats with 500 DSO Function Output NONE 1 von CheckMatri (int m[][COLUN 512]. int RON_STRE) 3 4

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

More Books

Students also viewed these Databases questions