Advertise with us

How to print pattern like this

Hi,

How to print pattern like this using C++?

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

Thanks in advance.

Last updated:6/15/2013 4:48:34 AM

1 Answers

AVADHESH PATEL
AVADHESH PATEL

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