#include<stdio.h>
int main( )
{
int n = 5, inc = 1, i, j,k; //n is number of stars to be printed in middle row
for (i = 1; i <= n && i >= 1; i = i + inc)
{
for (j = 1; j <= n - i; j++)
printf(" "); //prints a space
for (k = 1; k <= i;k++ )
printf("* "); //prints star and space
printf("\n"); //prints a new line
if (i == n)
inc = -1;
}
return 0;
}
No comments:
Post a Comment