Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!