Afisarea elementelor unei matrici

Se citeste o matrice patratica.Sa se afiseze elementele de pe diagonala secundara,elementele de pe diagonala principala,elementele de sub/desupra diagonalei secundare/principala. 
#include<iostream.h>
#include<stdio.h>

void main()
{
int i,j,n,a[20][20];
cin>>n;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
cout<<"diagonala principala"<<endl;
for(i=0;i<n;i++)
cout<<a[i][i]<<" ";

cout<<endl<<"diagonala secundara"<<endl;
for(i=0;i<n;i++)
cout<<a[i][n-1-i]<<" ";

cout<<endl<<"elementele de deasupra diagonalei principale"<<endl;
for(i=0;i<=n-2;i++)
for(j=i+1;j<=n-1;j++)
cout<<a[i][j]<<" ";

cout<<endl<<"elementele de sub diagonala principala"<<endl;
for(i=1;i<=n-1;i++)
for(j=0;j<=i-1;j++)
cout<<a[i][j]<<" ";

cout<<endl<<"elementele de deasupra diagonalei secundare"<<endl;
for(i=0;i<=n-2;i++)
for(j=0;j<=n-i-2;j++)
cout<<a[i][j]<<" ";

cout<<endl<<"elementele de sub diagonala secundara"<<endl;
for(i=1;i<=n-1;i++)
for(j=n-i;j<=n-1;j++)
cout<<a[i][j]<<" ";
}