Skip to content

Commit 65790ee

Browse files
Diamond_pattern
Program to Print diamond pattern using for loop
1 parent c5c05c2 commit 65790ee

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diamond_pattern

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
// your code goes here
6+
int n,i,j,k;
7+
cin>>n;
8+
for( i=1;i<=n;i++){
9+
for( j=1;j<=n-i;j++)
10+
cout<<" ";
11+
12+
for( k=1;k<=i*2-1;k++)
13+
cout<<"*";
14+
15+
cout<<endl;
16+
}
17+
for( i=n;i>=1;i--){
18+
for( j=1;j<=n-i;j++)
19+
cout<<" ";
20+
21+
for( k=1;k<=i*2-1;k++)
22+
cout<<"*";
23+
24+
cout<<endl;
25+
}
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)