Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int ROWS, starNumber, spaceNumber;
int rowCount, spaceCount, starCount, treeTrunkRows, treeTrunkSpaceCount;
printf ("Enter number of rows: ");
scanf ("%d", &ROWS );
printf("\n");
for(rowCount = 1; rowCount <= ROWS; rowCount++) {
starNumber = rowCount * 2 - 1;
spaceNumber = rowCount + ROWS - starNumber;
for(spaceCount = 0; spaceCount < spaceNumber; spaceCount++)
printf(" ");
for(starCount = 0; starCount < starNumber; starCount++)
printf("*");
printf("\n");
}
for(treeTrunkRows = 0; treeTrunkRows < 2; treeTrunkRows++) {
for(treeTrunkSpaceCount = 0; treeTrunkSpaceCount < (ROWS * 2 + 1)/2; treeTrunkSpaceCount++)
printf(" ");
printf("*\n");
}
}