// ex_ch6_4.c
#include <stdio.h>

const char SPACE = ' ';

int main(void)
{
	char extend_to;
	printf("Input uppercase letter to extend to: ");
	scanf("%c", &extend_to);
	
	int offset = extend_to - 'A';

	for (int row = 1; row <= offset + 1; row++)
	{
		// print the spaces
		for (int position = 0; position < (offset + 1 - row); position++)
		{
			printf("%c", SPACE);
		}

		// print the characters in ascending order
		for (int count = 0; count < row; count++)
		{
			printf("%c", 'A' + count);
		}

		// print the letters in descending order
		for (int count = row - 1; count > 0; count--)
		{
			/* subtract one, as the letter in the middle was
			already printed by the previous loop */
			printf("%c", 'A' + count - 1);
		}
		// row finished: print newline
		printf("\n");
	}

	return 0;
}