Write a program to print upper 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<<"Upper tringular matrix is"<<endl;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i<=j)
{
cout<<"\t"<<a[i][j];
}
else
{
cout<<"\t ";
}
}
cout<<endl;
}
getch();
}
==OUTPUT==
do u really think that its a true upper triangula matrix??????? :o
ReplyDeleteWhat are you saying?
DeleteNice job really appreciate it 😋😋
DeleteKhadija, you can print zeros in the place of empty spaces if you want in that upper triangular matrix
DeleteI gettit. Shouldn't that upper triangular matrix be along the main diagonal right?
DeleteNice Job my friend.............
ReplyDeleteyour are a programmer............
Good program sir.
ReplyDelete