logo CodeStepByStep logo

sixDays

Write a complete program that prints the following cumulative song as console output. Use functions to capture the structure of the song and to eliminate redundancy. For example, no complete line of output should be printed in two or more places in your code.

On the 1st day of "Xmas", my true love gave to me
a partridge in a pear tree.

On the 2nd day of "Xmas", my true love gave to me
two turtle doves, and
a partridge in a pear tree.
    
On the 3rd day of "Xmas", my true love gave to me
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 4th day of "Xmas", my true love gave to me
four calling birds,
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 5th day of "Xmas", my true love gave to me
five golden rings,
four calling birds,
three French hens,
two turtle doves, and
a partridge in a pear tree.

On the 6th day of "Xmas", my true love gave to me
six geese a-laying,
five golden rings,
four calling birds,
three French hens,
two turtle doves, and
a partridge in a pear tree.
Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.