Skip to main content

Pattern 4 C++ Program

    Q4 ).  Write the code for given below pattern

 

 

 

 => C++ Coding :

#include<iostream>
using namespace std;

int main(){

int n;
cout<<"Enter the size of input : ";
cin>>n;

for(int i=1;i<=n;i++){

if(i==n){
    break;
}
  for(int j=1;j<=n-i;j++){
        cout<<"  ";
    }

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

}


for(int i=1;i<=n;i++){

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

  cout<<endl;

  for(int j=1;j<=i;j++){
        cout<<"  ";
    }




}


}

 

Comments