#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 Upper triangle elements:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(j<i)
{
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 Upper triangle elements:");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(j<i)
{
printf("\n %d",a[i][j]);
}
}
}
getch();
}
No comments:
Post a Comment