Given an M × N matrix mat that has all of its elements initialized to 0, write a C++ code fragment to store 1's along mat's main diagonal while leaving all other entries unchanged.

Example:
1 0 0 0
0 1 0 0
0 0 1 0


for (int i = 0; i < M; ++i)
mat[i][i] = 1;

Computer Science & Information Technology

You might also like to view...

In order to decrease download time, consider using ________ images on your Web pages

Fill in the blank(s) with correct word

Computer Science & Information Technology

The default importance level for all new messages is ____ importance.

A. low B. high C. normal D. urgent

Computer Science & Information Technology