#include <stdio.h>
void main()
{
// Incremental counting variables, used for counters for loops
int i, j, x;
// Regular variables to determine tree size, amount of spaces and total spaces
int tree_Size, spaces, total_Spaces;
// Character variables for each characer inputted by the user
char tree_Characters, tree_Top, tree_Trunk, tree_Base, tree_Middle, null_Terminator;
printf("Enter characters to use --> ");
scanf("%c", &tree_Top);
// Determine whether the first character holds any data
if (tree_Top == '\n') {
printf("Fail, tree_Top is null\n");
return;
}
else if (tree_Top != '\n')
scanf("%c", &tree_Trunk);
// Determine whether the second character holds any data
if (tree_Trunk == '\n') {
printf("Fail, tree_Trunk is null\n");
return;
}
else if (tree_Trunk != '\n')
scanf("%c", &tree_Base);
// Determine whether the third character holds any data
if (tree_Base == '\n') {
printf("Fail, tree_Base is null\n");
return;
}
else if (tree_Base != '\n')
scanf("%c", &tree_Middle);
// Determine whether the fourth character holds any data
if (tree_Middle == '\n') {
printf("Fail, tree_Middle is null\n");
return;
}
else if (tree_Middle != '\n')
scanf("%c", &null_Terminator);
/* Determine whether the fifth character holds any data, if it does, display
an error message and terminate the program */
if (null_Terminator != '\n') {
printf("Fail, null_Terminator is NOT null\n");
return;
}
// If it does not hold data, continue with program execution
else if (null_Terminator == '\n') {
printf("Enter size of tree --> ");
scanf("%d", &tree_Size);
// Check if size of tree does not exceed 20 or fall below 1
if (tree_Size < 1 || tree_Size > 20) {
printf("ERROR: Must enter a tree size between 1 and 20!");
}
else
{
//For handling top part of tree
for (i = 0; i <= tree_Size; i++) {
total_Spaces = tree_Size - i;
//Determine spaces before each number for pyramid
for (spaces = 1; spaces <= total_Spaces; spaces++)
//Make first line always one number
for (j = -1; j < i; j++)
if (j <= -1)
else if (j > -1)
printf("%c%c", tree_Top, tree_Top
);
}
//For handling stem and base of tree
for (i = 0; i <= tree_Size; i++) {
//if handling stem
if (i < tree_Size) {
for (spaces = 1; spaces <= tree_Size; spaces++)
}
//else if handling base
else if (i == tree_Size) {
for (x = 0; x < tree_Size; x++) {
}
for (x = 0; x < tree_Size; x++) {
}
}
}
}
}
}