Flag Discuss with colleagues and IITians> C++...
question mark

Write a program in C++ to display a matrix in ascending order

Anupam Dalmia , 15 Years ago
Grade 10
anser 1 Answers
SAGAR SINGH - IIT DELHI

Dear student,

#include  <iostream>

using namespace std;

#define  m  3

#define  n  3

 

int main()

{

     int  i, j;

     int  x[m][n]={{10,25,33}, {21,32,43},{20,42,51}};

     cout<<"\n3x3 arrays' subscripts and\n";

     cout<<"their respective elements\n";

     cout<<"--------------------------\n";

     // the outer for loop, reading the row by row...

     for(i=0; i<m; i++)

            // the inner loop, for every row, read every column by column...

            for(j=0; j<n; j++)

                  cout<<"["<<i<<"]"<<"["<<j<<"]"<<"="<<x[i][j]<<"\n";

     return 0;

}

 

ApprovedApproved
Last Activity: 15 Years ago
star
LIVE ONLINE CLASSES

Prepraring for the competition made easy just by live online class.

tv

Full Live Access

material

Study Material

removal

Live Doubts Solving

assignment

Daily Class Assignments