-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPattern.cpp
More file actions
50 lines (44 loc) · 943 Bytes
/
Pattern.cpp
File metadata and controls
50 lines (44 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Program to print half pyramid or inverted half pyramid pattern according to users choose.
#include<iostream>
using namespace std;
void Halfpyramid()
{
int row;
cout<<"Enter the number of rows:-";
cin>>row;
for(int i=1;i<=row;i++)
{
for(int j=1;j<=i;j++)
{ //chutiye saale
cout<<"* ";
}
cout<<endl;
}
}
void Inverted_halfpyramid()
{
int row;
cout<<"Enter the number of rows:-";
cin>>row;
for(int i=row;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
cout<<"* ";
}
cout<<endl;
}
}
// this is main function
int main()
{
int choose;
cout<<"1.Half Pyramid \n2.Inverted Half Pyramid"<<endl<<"Select your choose from above:";
cin>>choose;
if(choose==1)
Halfpyramid();
else if(choose==2)
Inverted_halfpyramid();
else
cout<<"Invalid choose , try again.";
}