> I'm trying to do a shape of star.
Start by drawing out several examples on graph paper.
The point of the exercise is to find the patterns between the size of the star
Code:
printf ("Enter size (10-20)\n");
scanf (" %d", &s);
and what the final shape is.
Say you wanted to draw a triangle of height 6 (h=6)
Code:
.....*
....***
...*****
..*******
.*********
***********
So there are a couple of things to notice
- the number of leading spaces counts down one for each successive row.
- the number of stars increases by two for each successive row.
Code:
for ( row = 0 ; row < h ; row++ ) {
leading_spaces = h - row - 1;
num_stars = row * 2 + 1;
}