pretty much confused...about this

one of students wants to get output as upper right and upper left elements of matrix

/* Declaration Of Header Files */
# include <iostream.h>
# include <conio.h>

/* Start Of Main Program */
void main()
{

/* Declaration Of Variables */
int i, j, r = 0, c = 0;
int a [ 10 ][ 10 ];
clrscr();

/* Asking For The Input From User */
cout << " Enter Number Of Rows & Columns Of 2D Array [ Matrix ] : ";
cin >> r >> c ;

// Accepting Values Of 2D Array [ Matrix ]
cout << " Enter " << r * c << " Values for 2D Array : ";
for ( i = 0; i < r; i++ )
{
for ( j = 0; j < c; j++ )
{
cin >> a [ i ][ j ];
}
}

// Printing Values Of 2D Array [ Matrix ]
cout << " Values Of 2D Array [ Matrix ] Are : ";
for ( i = 0; i < r; i++ )
{
cout << " \n ";
for ( j = 0; j < c; j++ )
{
cin >> a [ i ][ j ];
}
}

/* Source Code For Computing Upper Right & Lower Left Triangles Of Matrix If & Only If Rows & Columns Are Equal */
if(r==c)
{
cout<<" \n Upper Right Triangle Of Matrix Is : ";
for(i=0; i<r; i++)
{
cout<<"\n";
for(j=0; j<c; j++)
{
if(j>=i)
{
cout<<a[i][j]<<"\t";
}
else
{
cout<<"\t";
}
}
}

cout<<" \n Lower Left Triangle Of Matrix Is : ";
for(i=0; i<r; i++)
{
cout<<"\n";
for(j=0; j>c; j++)
{
if(j>=i)
{
cout<<a[i][j]<<"\t";
}
else
{
cout<<"\t";
}
}
}
}
else
{
cout<<" \n Upper Right & Lower Left Triangles Of Matrix Are Not Possible";
}
getch();
}

required output:
upper_right
123
56
9
upper_left
123
45
7
one of students wants to get output as upper right and upper left elements of matrix
pretty much confused...about this

Yes, we too.

Why do you care about one of the students, unless you are the teacher? Why confusion, if you are the teacher?

What is the actual question?


PS. Please use code tags and systematic indentation when posting code.
See http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.