Wednesday, 1 October 2014

WAP to print the Upper triangle of the matrix

#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
int a[10][10],i,j,k;
printf("\nEnter the Matrix of 3X3 : ");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("The Matrix is : \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("\t%d",a[i][j]);
}
printf("\t\n");
}
printf("\n Upper triangular Matrix is: \n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i>=j)
{
printf("\t%d",a[i][j]);
}
else
{
printf("\t0");
}
}
printf("\n");
}
getch();
}

No comments:

Post a Comment

Please write your doubts