This C program is to create the pyramid of the user's entered height. But it doesn't seem to work as intended. The while loop isn't increasing the k variable. Please, help it, where am I at fault?
#include <stdio.h>
int main()
{
int height, i, j, k = 0;
printf("This program is to make a pyramid\n\n");
printf("Enter the pyramid height: \n");
scanf("%d", &height);
for (i = 1; i <= height; i++)
{
for (j = 1; j <= height - i; j++)
{
printf(" ");
}
while (k != 2 * i - 1)
{
printf("*");
++k;
}
printf("\n");
}
return 0;
}