Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

C++ Please You work on a website called fiver, which is a place that people can pay for small tasks to be done. You have

C++ Please

You work on a website called fiver, which is a place that people can pay for small tasks to be done. You have been paid to fill in matrices with ones and zeros. For reasons you don't understand you have to fill in each matrix with all zeros except along the bottom left to top right diagonal. That will be filled with ones.

0 0 1 0 1 0 1 0 0 

Above is an example of a filled 3x3 matrix. Below is a 2x2.

0 1 1 0 

You decide to write a program to do it for you. Your program will take one integer input that specifies the dimension of the 2D array. This integer should be in the range of 1 and 100. If not, the program will issue and error message and exit.

Out of range. 

If the input integer is between 1 and 100, the program will initialize the elements of the 2D array as described above. Then the program will output these initialized values in the row major/dominant fashion (i.e., from the top to down and left to right). For example, for the above 3x3 matrix, the program will output

0 0 1 0 1 0 1 0 0 

For the 2x2 matrix, it will output

 0 1 1 0 

*Note: output for row major and column major order is the same in this format. Google row major order if you don't know what that is.

Hint: you need to declare a 2D matrix with dimension 100. The following is an example*

int numMatrix[100][100];

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions