Search⌘ K

Exercise 8: if/else Statements

Explore how to use if else statements in R to evaluate conditions and print specific results. This lesson helps you understand basic conditional decision-making by testing multiples of numbers and outputting corresponding messages with the cat function.

Problem Statement

Given a number, print foo if the number is a multiple of 33, bar if it is a multiple of 55 and foo bar if it’s a multiple of both 33 and 55.

Use cat() to display your output.

Input

A testVariable containing the number being tested.

Output

The correct statement corresponding to the condition of the number.

Sample Input

45

Sample Output

foo bar

Test Yourself

Write your code in the given area. If you get stuck, you can look at the solution.

R
# Write your code here
cat(" ")