(Diamond of Asterisks) Write a program that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single blank or a single newline. Maximize your use of repetition (with nested for statements) and minimize the number of output statements.

*
***
*****
*******
*********
*******
*****
***
*


```
// Drawing a diamond shape with asterisks using nested control statements.
#include
using namespace std;

int main()
{
// top half
for ( int row = 1; row <= 5; row++ )
{
// print preceding spaces
for ( int space = 1; space <= 5 - row; space++ )
cout << ' ';

// print asterisks
for ( int asterisk = 1; asterisk <= 2 * row - 1; asterisk++ )
cout << '*';
cout << '\n';
} // end for

// bottom half
for ( int row = 4; row >= 1; row-- )
{
// print preceding spaces
for ( int space = 1; space <= 5 - row; space++ )
cout << ' ';

// print asterisks
for ( int asterisk = 1; asterisk <= 2 * row - 1; asterisk++ )
cout << '*';

cout << '\n';
} // end for

cout << endl;
} // end main
```

Computer Science & Information Technology

You might also like to view...

A JavaFX Button’s event handler receives a(n) ________, which indicates that the Button was clicked.

a. ButtonEvent b. ObjectEvent c. ControlEvent d. ActionEvent

Computer Science & Information Technology

Perceived usefulness and ease of use of a system influence an individual's attitude toward the system.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Margins can be set by either typing in the desired value or using the ________

A) vertical scroll bar. B) spin arrows. C) align menu. D) horizontal scroll bar.

Computer Science & Information Technology

What command would allow you to view a list of all installed drivers?

A) HELP B) IPCONFIG C) LISTSVC D) MSINFO32

Computer Science & Information Technology