# 4.13. Activecode Exercises¶

Answer the following Activecode questions to assess what you have learned in this chapter.

Fix the code below so that it prints “THE TEAM” “THE TEAM” “THE TEAM” on three separate lines.

Below is one way to fix the program. Since we want “THE TEAM” to print three times, we must check all three conditons. this means changing the else if statements to if statements.

Selecting from: cond_rec_a2, cond_rec_a2_pp

Fix the infinite recursion in the code below. The function should not count any numbers after 10 (the highest numbers that should print are 9 or 10). When it is done counting, the function should print that.

Below is one way to fix the program. The infinite recursion happens when we use an odd number as an argument. By checking that a number is less than 99, the highest numbers to recurse are 98 and 97. 98 + 2 == 100 and 97 + 2 == 99, so we never count past 100.

Selecting from: cond_rec_a4, cond_rec_a4_pp

Finish the code below so that the function will continue to ask for input until the user guesses the word correctly.

Below is one way to complete the program.

Selecting from: cond_rec_a6, cond_rec_a6_pp

Write the function goodVibes that prints “I’m having a mood day!” depending on the value of mood. If mood is “bad”, then the function should not do anything since it’s good vibes only. Be sure to include any necessary headers.

Below is one way to write the program. The return allows the function to exit if there are bad vibes in the room. Otherise, the function prints as directed.

Write the function countdown that takes a positive integer and decrements it until eaching zero, printing the number at each step of the way. Once it reaches zero, it should print “Blastoff!”