2/23/2009

C Program To Perform Upper Bound And Lower Bound Matrix


/* C Program To Perform Upper Bound And Lower Bound Matrix */
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],u[10][10],l[10][10],i,j,m,n;
clrscr();
 printf("Enter the order of the matrix\n");
  scanf("%d%d",&m,&n);
 if(m==n)
 {
 printf("Enter the element of the matrix\n");
 for(i=0;i<m;i++)
  {
  for(j=0;j<m;j++)
   {
   scanf("%d",&a[i][j]);
   }
  }

 for(i=0;i<m;i++)
  {
  for(j=0;j<m;j++)
   {
   u[i][j]=a[i][j];
   l[i][j]=a[i][j];
   }
  }

 printf("Upper bound traingularised matrix\n");
 for(i=0;i<m;i++)
  {
  for(j=0;j<m;j++)
   {
   if(i>j)
    {
    u[i][j]=0;
    }
   printf("%d ",u[i][j]);
   }
  printf("\n");
  }

 printf("Lower bound traingularised matrix\n");
 for(i=0;i<m;i++)
  {
  for(j=0;j<m;j++)
   {
   if(i<j)
    {
    l[i][j]=0;
    }
   printf("%d ",l[i][j]);
   }
  printf("\n");
  }
 }
 else
  printf("The orders are not equal\n");
 getch();
}
Out Put:
C Program To Perform Upper Bound And Lower Bound Matrix

No comments:

Post a Comment