Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write a C++ program to draw a heart and share to your special one in special occasion. The output of the program is below:

Please write a C++ program to draw a heart and share to your special one in special occasion. The output of the program is below:

image text in transcribed

Please use functions and loops for this program, rather than print out everything directly, therefore you are only allowed to use the following output syntax:

cout

cout

cout

The heart can be sperate to two parts:

1. In the upper part, there are two trapeziums.

image text in transcribed

Line 1: 4 blanks, 3 stars, 9 blanks, 3 stars

Line 2: 3 blanks, 5 stars, 7 blanks, 5 stars

Line 5: 0 blanks, 11 stars, 1 blank, 11 stars

2. In the lower part, there is one inverted triangle.

image text in transcribed

Line 1: 1 blank, 21 stars

Line 2: 2 blanks, 19 stars

Line 11: 11 blanks, 1 star

To demonstrate the reusability of function, please write the program with the following step:

In main function:

1. Initialize the number of blanks and stars in the first line of the upper part heart.

2. Initialize the number of blanks and stars in the first line of the lower part heart.

3. Write a loop to print out the upper part of the heart, in this loop:

a. Call a function UpperHeart to print a line for the upper part of the heart.

b. Adjust the number of blanks and stars to a suitable value for printing next line.

4. Write a loop to print out the lower part of the heart, in this loop:

a. Call a function LowererHeart to print a line for the lower part of the heart.

b. Adjust the number of blanks and stars to a suitable value for printing next line.

In UpperHeart function:

1. Write a loop to print the first part of the blanks.

2. Write a loop to print the first part of the stars.

3. Write a loop to print the second part of the blanks.

4. Write a loop to print the second part of the stars.

5. End of a line.

In LowererHeart function:

1. Write a loop to print the blanks.

2. Write a loop to print the stars.

3. End of a line.

Transcribed image text

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

=+b. Who would the brand be as a famous person?

Answered: 1 week ago