#include<conio.h>
#include<stdio.h>
void main()
{
int i,j,a[20][20],k=1,n;
printf("\n Enter the size of square matrix");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=k;
k++;
}
}
printf("\n Forward Diagonal elements:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
printf("\n %d",a[i][j]);
}
}
}
getch();
}
#include<stdio.h>
void main()
{
int i,j,a[20][20],k=1,n;
printf("\n Enter the size of square matrix");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=k;
k++;
}
}
printf("\n Forward Diagonal elements:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
{
printf("\n %d",a[i][j]);
}
}
}
getch();
}
No comments:
Post a Comment