Answer in C++:
#include <iostream>
using namespace std;
int main() {
char letter[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char user_letter;
int letter_number;
//array of strings
string diamond[100];
//get the letter
cout << "Input a letter: "; cin >> user_letter;
//search for letter number in the array letter
for (int i = 0; i < 26; i++) {
if (letter[i] == user_letter) {
letter_number = i;
break;
}
}
//construct diamond
for (int i = 0; i < letter_number+1; i++) {
//add initial spaces
for (int j = 0; j < letter_number-i; j++) {
diamond[i] += " ";
}
//add letter (first time)
diamond[i] += letter[i];
//add space between letters
if (letter[i] != 'A') {
for (int j = 0; j < 2*i-1; j++) {
diamond[i] += " ";
}
//add letter (second time)
diamond[i] += letter[i];
}
//add last spaces
for (int j = 0; j < letter_number-i; j++) {
diamond[i] += " ";
}
}
//draw the diamond
int j = 1;
for (int i = 0; i < 2*letter_number+1; i++) {
if (i < letter_number+1)
cout << diamond[i];
else {
cout << diamond[i-2*j];
j++;
}
cout << endl;
}
return 0;
}