(Diamond of Asterisks) Modify Exercise 4.23 to read an odd number in the range 1 to 19 to specify the number of rows in the diamond, then display a diamond of the appropriate size.
What will be an ideal response?
```
// Drawing a diamond shape with the specified size.
#include
using namespace std;
int main()
{
int size; // number of rows in diamond
// loop until valid input
do
{
cout << "Enter an odd number for the diamond size (1-19): \n";
cin >> size;
} while ( ( size < 1 ) || ( size > 19 ) || ( ( size % 2 ) != 1 ) );
// top half
for ( int rows = 1; rows <= size - 2; rows += 2 )
{
// print preceding spaces
for ( int space = ( size - rows ) / 2; space > 0; space-- )
cout << ' ';
// print asterisks
for ( int asterisk = 1; asterisk <= rows; asterisk++ )
cout << '*';
cout << '\n';
} // end for
// bottom half
for ( rows = size; rows >= 0; rows -= 2 )
{
// print preceding spaces
for ( int space = ( size - rows ) / 2; space > 0; space-- )
cout << ' ';
// print asterisks
for ( int asterisk = 1; asterisk <= rows; asterisk++ )
cout << '*';
cout << '\n';
} // end for
cout << endl;
} // end main
```
You might also like to view...
Which SAMM practice focuses on the inspection of software in the runtime environment to find security problems?
A. Code review B. Security testing C. Software review D. Design review
________ allows restricted access to blobs, tables, containers and queues for a set time period.
a) Windows Cloud Foundation (WCF). b) Windows Azure AD Access Control. c) Active Directory Federation Services. d) Windows Azure Shared Access Signatures.
What is a multiple master?
What will be an ideal response?
You have been tasked with implementing a server infrastructure that allows clients to use virtual machine and session-based desktops to access and run applications on servers. What role should you install for this purpose?
A. Volume Activation Services B. Remote Desktop Services C. Remote Access Services D. Network Controller Services