how can i create something of this sort:

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

this is my source code:

#include <stdio.h>


int main()
{
int i;
i = 1;
while(i <= 5)
{


printf("*\n");


i++;


}



getchar();
}

With two for loops, one nested inside the other. The outer for loop manages the rows, and the inner for loop manages the variables for the columns inside the row being printed.

Remember that the total width of the diagram, minus the number of stars you print on that row, is the number of spaces that must be printed on the row.

#include<stdio.h>
#define LINES 9
int main()
{
int i,j;
for(i=1;i<=LINES;i++)
{
    if(i-1<=LINES/2)
      {
       for(j=1;j<=i;j++)
            printf("*");
      }
    else
     {
       for(j=LINES;j>=i;j--)
            printf("*");
      }
printf("\n");
}
getchar();
}

Just change the define number as per the number of lines u require

commented: We do NOT do homework for others! That's called cheating! We help them find their own solutions. -4

thank you!

commented: gratitude..! thanks! some bozo reduced my points saying I was doing others homework.. LOL! X_X +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.