Exercise 11: for Loops
Let's test your ability to write for loop.
We'll cover the following
Problem Statement
For each element in the given vector, print foo if it is a multiple of , bar if it is a multiple of and foo bar if it’s a multiple of both and .
Use the
cat()
function for printing. Remember to print the number as well as the respective statement!
Input
A testVariable
containing the vector of numbers
Output
The element and the attached statement with it.
Sample Input
testVariable -> c(3, 5, 15)
Sample Output
3 foo 5 bar 15 foo bar
Test Yourself
Write your code in the given area. If you get stuck, you can look at the solution.
# Write your code herecat(" ")