small problems .. need help ..

Hi All ..

I'm having small problems with this program ..

The program suppose to print :

1. Main Diagonal Elements and its Sum .

2. Inverse Diagonal Elements and its Sum .

3. Max and Min element and their positions .

4. The Elements Upper the Main Diagonal .

5. The Elements Under the Main Diagonal .

This is the code :

Code:

`#include <iostream>`

#include <conio>

#include <iomanip>

int main()

{

int A[5][5]={{1,2,3,4,5},{6,7,8,9,10},{11,12,13,14,15},{16,17,18,19,20},{21,22,23,24,25}};

int i , j , sum=0 , r_n=0 , c_n =0 , r_m = 0 , c_m = 0 , up=0 , low=0;

int min = A[0][0];

int max = A[0][0];

cout<< "Array Elements Are" << endl;

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

{ for (j=0;j<5;j++)

{ cout<< setw(5) << A[i][j];

}

cout<< "\n";

}

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

{ for (j=0;j<5;j++)

if (i==j)

{

sum+=A[i][j];

cout<< "Main Diagonal Elements are : " << A[i][j] << endl;

}

}

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

{ for (j=0;j<5;j++)

{ if (A[i][j] > max)

{

max= A[i][j];

r_m= i;

c_m= j;

}

if (A[i][j]< min)

{

min=A[i][j];

r_n=i;

c_n=j;

}

}

}

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

{ for (j=0;j<5;j++)

{ if ((i!=j) && (j > i) )

{

up+=A[i][j];

cout<< "The upper Elements are : " << A[i][j]<< endl;

}

{

if (j<i)

{

low+=A[i][j];

cout<< "The Lower Elements are : "<< A[i][j]<< endl;

}

}

}

}

cout<< "\n\nSum of Main Diagonal Elements is : " << sum;

cout<< endl << "The Minimum Element =" << min << " At Row " << (r_n+1) << " Col " << (c_n+1);

cout<< endl << "The Maximum Element =" << max << " At Row " << (r_m+1) << " Col " << (c_m+1);

cout<< "\nSum of Upper Elements : " << up << endl;

cout<< "\nSum of Lower Elements : " << low << endl;

getch();

return 0;

}

__________________________

The FIRTS PROBLEM is in this loop :

Code:

`for (i=0;i<5;i++)`

{ for (j=0;j<5;j++)

if (i==j)

{

sum+=A[i][j];

cout<< "Main Diagonal Elements are : " << A[i][j] << endl;

}

}

The OUTPUT is :

Code:

`Main Diagonal Elements are : 1`

Main Diagonal Elements are : 7

Main Diagonal Elements are : 13

Main Diagonal Elements are : 19

Main Diagonal Elements are : 25

it will repeat the statements : Main Diagonal ......

How can I fix it ??

it's the same problem in upper , lower Elements ..

I know it's noob problem but I really don't know how to fix it ><" ...

_________________________

The SECOND PROBLEM is I dunno how to print the INVERSE DIAGONAL ... :confused:

Please help me even with small explanation .. :(