Skip to content

Commit afd9d71

Browse files
Create Code to Print Lower half and Upper half of Triangle Matrix.cpp
1 parent d7346c3 commit afd9d71

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// C++ Program to Print Lowerhalf and Upperhalf of Triangle Matrix
2+
3+
4+
#include<iostream>
5+
6+
using namespace std;
7+
8+
int main()
9+
{
10+
int a[10][10],i,j,m;
11+
cout<<"Enter size of the Matrix(min:3,max:5):";
12+
cin>>m;
13+
cout<<"\nEnter the Matrix row wise:\n";
14+
15+
for(i=0;i<m;i++)
16+
for(j=0;j<m;++j)
17+
cin>>a[i][j];
18+
19+
cout<<"\n\n";
20+
21+
cout<<"Upperhalf of Triangle Matrix :: \n";
22+
23+
for(i=0;i<m;++i)
24+
{
25+
for(j=0;j<m;++j)
26+
{
27+
if(i<j)
28+
cout<<a[i][j]<<" ";
29+
else
30+
cout<<" ";
31+
}
32+
33+
cout<<"\n";
34+
}
35+
36+
cout<<"\n";
37+
38+
cout<<"Lowerhalf of Triangle Matrix :: \n";
39+
40+
for(i=0;i<m;++i)
41+
{
42+
for(j=0;j<m;++j)
43+
{
44+
if(j<i)
45+
cout<<a[i][j]<<" ";
46+
else
47+
cout<<" ";
48+
}
49+
cout<<"\n";
50+
}
51+
52+
return 0;
53+
}

0 commit comments

Comments
 (0)