I am beginner in C++.I write the code to print half diamond.
*
**
***
****
***
**
*
My Code is given below.I want your suggestion regarding code logic,No of loops used(i used 4).Or how can i further simplify keeping in mind that the concept of efficient coding.
Code:
int main()
{
int row,column,limit=4;// limit is the maximum no of stars to be printed before //decrementing stars
row=1;

for(;row<=limit;row++) //This loop will run 4 times
{
   for(column=1;column<=row;column++)//this loop will prnt stars
   cout<<"*";

cout<<endl;

   if (column==(limit+1)) //To check when stars will be decremented
  {
     int i=limit-1;
     for(;i > 0;i--)
     {
         for(int j=1;j<=(limit-1);j++)
         cout<<"*";

     cout<<endl;
     limit--;
    }
  }

}

return 0;
}

Last edited by shabbir; 12Oct2009 at 17:35.. Reason: Code blocks