Read a single character from ‘A’ through ‘Z’ and produces output in the shape of a pyramid composed of the letters up to and including the letter that is input.

The top letter in the pyramid should be ‘A’, and on each level, the next letter in the alphabet should fall between two copies of the letter that was introduced in the level above it.

For example, if the input is ‘E’,the output looks like the following:


A
ABA
ABCBA
ABCDCBA
ABCDEDCBA

Thanks in advance!!

<broken record>
What have you tried so far? Do you have any code? If so, please post it. If not, go give the assignment an honest attempt before asking for help!
</broken record>

Thank you very much for your help !!
Here is my attempt of solving this problem and the problem is solved

#include <iostream>
#include <ctype.h>
using namespace std;

int main()
{
	int n, g;
	char Input = 'A';
    int intValue = 65;

	while(Input != '0')
	{
		cout << "Enter Character (0 to exit): ";
		cin >> Input;
		
		if(Input == '0')
			break;
		
		intValue = toupper(Input) - 64;
	
		for(int i = intValue; i >= 1; i--)
		{
			for(n = 1; n <= intValue - i + 1; n++)
				cout << char(n + 64);
			for(g = n - 2; g >= 1; g--)
				cout << char(g+64);
			cout << endl;
		}
		cout << endl;		
	}
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.