Question: Using loops and arrays write a SWIFT program to do the following: Create a * based Christmas tree that looks like the following: * ***

Using loops and arrays write a SWIFT program to do the following:

  • Create a * based Christmas tree that looks like the following:
    • *
    • ***
    • *****
    • *******
    • *********
    • *
  • Use a loop to algoritmically create the top five lines of the tree
    • The first line has 4 spaces followed by 1 *
    • The next line has 3 spaces followed by 3 *
    • The next line has 2 spaces followed by 5 *
    • The next line has 1 spaces followed by 7 *
    • The last line has 0 spaces followed by 9 *
  • Store each output line on the tree in an Array
  • Finally use one more array to output the contents of your Array

Good luck!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!