thanks for your help the last time, guys. I now have a question re: the "for" structure.
This code for printing a diamond has more than one "for" statement and I don't understand how to interpret it. I have seen the output, but I can't follow it from the code.
Could someone please explain?
here goes the code...
Code:
int main ()
{
int line, space, asterisk;
for (line = 1; line <= 9; line += 2) /* Top half */
{
for (space = (9 - line) /2; space > 0; space--)
printf (" ");
for (asterisk = 1; asterisk <= line; asterisk++)
printf("*");
printf ("\n");
}
for (line = 7; line >= 0; line -= 2) /*Bottom half */
{
for (space = (9 - line) /2; space > 0; space--)
printf (" ");
for (asterisk = 1; asterisk <= line; asterisk++)
printf("*");
printf ("\n");
}
return (0);
}
Code Tags added by Kermi3