I need help writing this program and it has to have user input. It has to be C++ language


1) Write a program that displays the following diamond shape. You may use output statements that display either a single asterisk (*) or a single blank. Maximize your use of repetition (with ‘nested repetition’ statements) and minimize the number of output statements. You may not simply type the figure into the program, i.e., the program must calculate and display the entire figure.

Fig. 1
*
***
*****
*******
*********
*******
*****
***
*

2) Modify the program you wrote in 1), above to read an odd number from the user in the range of 5 to 19 to specify the number of rows in the diamond, and then display a diamond of the appropriate size.

line 0 has 1 star
line 1 has 3 stars
line 2 has 5 stars
line 3 has 7 stars
Without looking at the program how many stars does line 4 have? How many stars, call that number y, would line x have? Now try to write down on paper the logic you used to come up with those answers. Then try to write code that will print out y number of stars. Then, and only then try to write a program to display the top half of the "diamond". Finally repeat the whole process to do the bottom half of the diamond.

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.