Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

30 Jan 2014

LOWER TRIANGULAR MATRIX

Write a program to print lower triangular matrix in c++

#include<iostream.h>
#include<conio.h>
void main()
{   clrscr();
 int a[10][10],b[10][10],c[10][10];
 int i, j, n, m;
 int p,q;
 cout<<"enter no of rows of matrix\n";
 cin>>m;
 cout<<"enter no of colomns of matrix\n";
 cin>>n;
 cout<<"\n\nenter the elements of matrix\n";
  for(i=0;i<m;i++)
   {
    for(j=0;j<n;j++)
     {
      cout<<"a["<<i+1<<"]["<<j+1<<"]:= ";
      cin>>a[i][j];
     }
   }
  cout<<"\n\nmatrix u have entered is"<<endl;
  for(i=0;i<m;i++)
   {
    for(j=0;j<n;j++)
     {
      cout<<"\t"<<a[i][j];
     }
    cout<<endl;
   }
 cout<<"Lower tringular matrix is"<<endl;
  for(i=0;i<m;i++)
  {
   for(j=0;j<n;j++)
    {
     if(j<=i)
     {
      cout<<"\t"<<a[i][j];
     }
     else
     {
      cout<<"\t ";
     }
    }
    cout<<endl;
  }


getch();
}