Follow This Blog For more... 😊

Butterfly Pattern using C++ with code.

Butterfly Pattern using C++ with code.

CODE:


    #include<iostream>
    using namespace std;

    main()
    {
        int i,j,n;
       
        cout<<"Enter the number:";cin>>n;
       
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=i;j++)
            {
                cout<<"* ";
            }
            for(j=1;j<=n-i;j++)
            {
                cout<<"  ";
                cout<<"  ";
            }
            for(j=1;j<=i;j++)
            {
                cout<<"* ";
            }
            cout<<endl;
        }
        for(i=n;i>0;i--)
        {
            for(j=1;j<=i;j++)
            {
                cout<<"* ";
            }
            for(j=1;j<=n-i;j++)
            {
                cout<<"  ";
                cout<<"  ";
            }
            for(j=1;j<=i;j++)
            {
                cout<<"* ";
            }
            cout<<endl;
        }
    }


OUTPUT:



Comments

Popular Posts