C++ assignment question

Pages: 12
I am new to C++, currently taking a class at my local college, and I'm having trouble figuring this out..

"write a program that inputs a character from the keyboard and the outputs a large block letter "C" composed of that character."

If anyone can help I would really appreciate it!
Last edited on
Have you got some code?

We can help, but we can't do assignments for you.
I submitted my assignment once just using cout << "X\n"; to make the letter "C" but my professor said it was wrong. I'm just stumped.
The requirements sound strange. I assume your professor is wanting the uppercase of whatever letter is inputted. In that case, you have a toupper() function you can use. Or you can look at an ASCII chart and see if you notice a relationship between lowercase and uppercase letters, and write the function yourself.

http://www.ascii-code.com/
http://www.cplusplus.com/reference/cctype/toupper/
This is what I had originally done..

cout << " X X X\n";
cout << " X X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << " X X\n";
cout << " X X X\n";

The assignment doesn't mention anything about capital letters or anything like that. Unless this is wrong lol.
the coding got messed up when I pasted it :/
The way you're printing the letter probably isn't wrong - that meets up with his requirements.

However, you need to ask the user for a letter then print the "C" using whatever letter has been entered, rather than "X".

That is, if I have interpreted the requirements correctly.
I think your prof wants you to develop a loop structure to output a multi-line block letter.
1
2
3
4
5
6
7
8
9
10
EEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEE
EEE
EEE
EEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEE
EEE
EEE
EEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEE


So.. something like that, except with the letter C being printed to the screen as a block letter.
Oh, I get what you're saying now.

If that's all your professor had for this assignment, then what you did is just right. He should have more explicit instructors, we're programmers damnit! Not mind readers.

Anyways, he probably is wanting you to use a loop of some kind to generate this. If you notice, there's a pattern in what you did manually.
haha the assignment is out of Walter Savich's "problem solving with C++"

The example says it should look like this..

......X X X
....X......X
...X
...X
...X
...X
....X.....X
.....X X X

I used periods so it would look right lol

but this chapter doesn't say anything about a loop structure, I haven't gotten that far yet :/
Still, though, the assignment wants the letter composed of a character that the user has input.

So, if I input 'Y', it should be:
 YYY
Y   Y
Y
Y
Y
Y   Y
 YYY
I thought that's what I did lol, I can't find how to do that in the chapter for the life of me.
You almost have it. Instead of using X, use a variable. Keep it a char so people don't put in more than one character and screw it up.
So if I use something other than 'X' it should be right? Is there anything wrong with my coding? I just used X because that's what the example used..
You should use a variable, not a hard coded value.

If your professor didn't explicitly mention using a loop to draw then there's nothing wrong with the way you're drawing, other than the fact that you're using a hard coded value.
Last edited on
Nope. Now you're overthinking it. You were on the right track before. Just instead of outputting a hard coded value, output whatever value the user gave you.
haha well shit :/ I don't know what you mean by hard coded value. I just used x because that's what the example used. sorry guys, I literally just started this course last Monday
It's all good. We were all beginners at some point.
Tnobis try this:

int main(){

char X;
cout << "Enter a letter of choice: ";
cin >> X;

cout << " X X X\n";
cout << " X X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << "X\n";
cout << " X X\n";
cout << " X X X\n";
Last edited on
Pages: 12