Skip to content

Commit 1490f07

Browse files
authored
Sand glass pattern
1 parent aaea50a commit 1490f07

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Sand_glass_pattern.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int n=5,i,k,j;
6+
7+
for(i=n;i>=1;i--){ //outer loop
8+
9+
for(k=n-1;k>=i;k--){
10+
cout<<" "; //spacing
11+
}
12+
13+
for(j=i;j>=1;j--){ //inner loop
14+
cout<<"* ";
15+
}
16+
cout<<endl;
17+
18+
}
19+
20+
for(i=1;i<=5;i++){ //outer loop
21+
22+
for(k=i;k<n;k++){
23+
cout<<" "; //spacing
24+
}
25+
26+
for(j=1;j<=i;j++){ //inner loop
27+
cout<<"* ";
28+
}
29+
cout<<endl;
30+
31+
}
32+
33+
return 0;
34+
}

0 commit comments

Comments
 (0)