The program asks the user for the pyramid hight i.e: rows number, and prints out a pyramid.
for input of 5, the result should look like this:
*
***
*****
*******
*********
the code I wrote is:
#include <stdio.h>
void main()
{
int i, j, n = 0;
printf("enter pyramid hight: \t");
scanf("%d", &n);
// FOR EACH ROW:
for (i = 0; i < n; i++)
{
// print spaces till middle:
for (j = 0; j < (n - 1 - i); j++)
{
printf(" ");
}
// print stars:
for (j = 0; j < 2 * n + 1; j++)
;
{
printf("*");
// go to new row
printf("\n");
}
}
}
but the result is:
*
*
*
*
*
what could be going wrong exactly, I think the second loop may be the problem but I can't put my hand on the reason.