Hi,
I am have a problem trying to do chapter review question. It's not an assignment, I was just interested in trying it. Here is the question.
Ask user for a character...let's say it's an 'E'. Print this pyramid-type output:
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
The book suggests using an outer for loop for the rows, and three inner for loops to take care of the spaces, the ascending letters and the descending letters, respectively. I'm stumped. I have tried various increments/decrements and variables only to run into a wall each time.
Can anyone help me out with this? I don't really want the code, just some information that can get me to the correct end result. My idea for the rows is:
char ch;
int row;
for (row = 0; row <= ch - 'A'; row++)
This will give me the rows and I know the starting point for the spaces is (ch - 'A') - 1, although that may not be the best way to get it.
Thanks in advance for your help.
-Tyler
I am have a problem trying to do chapter review question. It's not an assignment, I was just interested in trying it. Here is the question.
Ask user for a character...let's say it's an 'E'. Print this pyramid-type output:
A
ABA
ABCBA
ABCDCBA
ABCDEDCBA
The book suggests using an outer for loop for the rows, and three inner for loops to take care of the spaces, the ascending letters and the descending letters, respectively. I'm stumped. I have tried various increments/decrements and variables only to run into a wall each time.
Can anyone help me out with this? I don't really want the code, just some information that can get me to the correct end result. My idea for the rows is:
char ch;
int row;
for (row = 0; row <= ch - 'A'; row++)
This will give me the rows and I know the starting point for the spaces is (ch - 'A') - 1, although that may not be the best way to get it.
Thanks in advance for your help.
-Tyler