#include <stdio.h>
#include <stdlib.h>
/* Puzzle L17 -- print a diagonal line of stars
|
| Print one star per line. Line 0 has a star in col 0,
| line one has a star in col 1, and so on for n lines.
*/
int main()
{
int line, col;
int n=15 ;
for ( line=0; line < n; line++ )
{
for ( col=0; col < line; col++ )
printf(".");
printf("*\n");
}
printf("\n");
return 0;
}
Comments: It is, perhaps, a "trick", that the star is printed outside of the inner loop. But, how else could you do it?