Click here to Skip to main content
15,742,180 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do I create a shape with an inputted character and width? (ex if I want to create a diamond using @ with 31 @symbols at the widest point?

What I have tried:

not sure how to start this program.
Updated 17-Sep-18 19:53pm

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
Start by breaking the task down: it's two halves, one to print the "increasing" chars:
And one to print the "decreasing" chars:
So start by thinking of it that way, and do each "half" separately.
Get the "top half" working first, then think about the bottom. The top is pretty easy: it's a loop to print the lines, then a loop inside that to print the characters. On teh first line, you need to print "x" spaces and "y" characters, where
2x + y = n
y = 2l + 1
Where l is the line number, zero based:
  @    x = 2, y = 1, l = 0, n = 5
 @@@   x = 1, y = 3, l = 1, n = 5
@@@@@  x = 0, y = 5, l = 2, n = 5
Start with that, and see how far you can get.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900