Home > DeveloperSection > Forums > How to print pattern like this
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    June-14-2013 11:48 PM

 Visual C++ Visual C++ 
Ratings:


 1 Reply(s)
 603  View(s)
Rate this:
Hi,

How to print pattern like this using C++?

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

Thanks in advance.



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-15-2013 4:48 AM

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";
  }
}

Don't want to miss updates? Please click the below button!

Follow MindStick