Write a recursive function void printPattern(string s). It will be passed a string of stars (e.g. "****") and should print out a pattern of stars that looks like this:
Write a recursive function void printPattern(string s). It will be passed a string of stars (e.g. "****") and should print out a pattern of stars that looks like this:
Write a recursive function void printPattern(string s). It will be passed a string of stars (e.g. "****") and should print out a pattern of stars that looks like this:
The returned value should be the string s repeated times times. You donβt have to worry about negative values of times. Note that the function header is there, you just need to fill in the body.
Say you were told to repeat the string "hello" 5 times and knew you could ask me what the value of repeating "hello" 4 times was. How could you get your answer?
Write a function double investment(double money, double interestRate, int years) that returns the final value of an amount of money invested at a given interest rate for a given number of years.
The interest rate will be given as a percentage (e.g., 5.0 for 5%). Compute simple interest for each year. E.g. Starting with 10000 and an interest rate of 5%, the interest earned for the first year will be 10000 * 0.05 = 500.
Write a function int investmentLength(double money, double goal, double interestRate) that returns the number of years it will take to reach the given investment goal if you start with the given amount of money and invest at the specified interest rate.
The interest rate will be given as a percentage (e.g., 5.0 for 5%). Compute simple interest for each year. E.g. Starting with 10000 and an interest rate of 5%, the interest earned for the first year will be 10000 * 0.05 = 500.
Each recursive case represents one more year of your money having been invested. It should return a value one larger than the result of the recursive call with updated parameters.
You can add another parameter. Although you do not have to, it may make the logic easier. If you want to do so, make sure it has a default value or you have a non-recursive version of the function to kick start things.
Write a function int numLegs(const vector<char>& animals, int curPosition = 0). The vector will consist only of the chars βcβ and βdβ representing "cow" or "duck". The function should calculate the total number of legs those animals have (assume no mutations or industrial accidents... a cow has 4 and a duck has 2).