#include<iostream.h>
#include<conio.h>
void func(int[10][10],int);
void main()
{clrscr();
int a[10][10],n;
cout<<"HIMANSHU SINGH\n";
cout<<"enter size and 2d array";
cin>>n;
cout<<"\n";
for(int x=0;x<n;x++)
{ for(int y=0;y<n;y++)
cin>>a[x][y];
}
func(a,n);
getch();
}
void func(int w[][10],int n)
{cout<<"DIAGONAL ELEMENTS ARE-\n";
for(int i=0;i<n;i++)
{ for(int j=0;j<n;j++)
{ if(i==j)
cout<<w[i][j];
else
cout<<"o ";
}cout<<endl;
}
cout<<"\n";
for(int p=0;p<n;p++)
{ for(int q=0;q<n;q++)
{ if((p==(n-1)-q))
cout<<w[p][q];
else
cout<<"o ";
} cout<<endl;
}
}
OUTPUT
No comments:
Post a Comment