HOW TO PRINT PATTERN LIKE THIS

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
 866  View(s)
Ratings:
Rate this:
Hi,

How to print pattern like this using C++?

    *
         * *
   * * * *
* * * * *

Thanks in advance.

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How to print pattern like this

    Hi, 


    Try this:

    int main( )
    {
     int i,j;
      for(i==0;i<5;i++)
      {
        for (j=5;j>0;j--)
        {
          if( j<=i )
            {
              cout<<"*";
              cout<<" ";
             }
          else
          {
            cout<<" ";
            cout<<" ";
           }
         }
      cout<<"\n";
      }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!