Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 14: Drawing Stars with Recursion Key Concepts: Recursion Suppose you are bui

ID: 3691786 • Letter: L

Question

Lab 14: Drawing Stars with Recursion

Key Concepts: Recursion

Suppose you are building a program which draws several stars on the console. On the first three lines, there should be 1, 2, and 3 stars, respectively. On all subsequent lines, the number of stars should either be twice the number of stars 2/3 of the way up the screen, for lines numbers that are exact multiples of three, or otherwise 2 more than the preceding line. Write a recursive definition for the number of stars on each line.

Then, implement the recursive function from above, add a method to draw any number of stars (that can be iterative, i.e. using a loop, or it can be recursive), and call it enough times print stars on 54 lines.

The first few lines should look like this:

This is similar to, but different from previous star-drawing exercises. But, note that we did something like this before with nested loops, whereas now we're doing it with recursion.

MUST BE DONE IN C++

Explanation / Answer

  

01 #include <iostream>