Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Commit

Permalink
Create butterflypattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilshad-mohammad authored Oct 30, 2024
1 parent 5aefa58 commit 93975c1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Beginner Level 📁/Patterns/butterfly/butterflypattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include<iostream>
using namespace std;

int main( )
{
int n;
cin>>n;

for(int i=1;i<=n;i++){
for(int j=1;j<=i;j++){
cout<<"*";
}
int space= 2*n - 2*i;
for( int j=1;j<=space;j++){
cout<<" ";
}
for(int j=1;j<=i;j++){
cout<<"*";
}
cout<<endl;
}

for(int i=n;i>=1;i--){
for(int j=1;j<=i;j++){
cout<<"*";
}
int space = 2*n - 2*i;
for( int k=1;k<=space;k++){
cout<<" ";
}
for(int j=1;j<=i;j++){
cout<<"*";
}
cout<<endl;
}
}

0 comments on commit 93975c1

Please sign in to comment.