Exercise 10: while Loops

Let's test your ability to write while loop.

Problem Statement

Run a loop from 11 to 2020 and for each number, print foo if it 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() for printing. Remember to print the number as well as the respective statement!

Sample Output

3 foo 5 bar 6 foo 9 foo 10 bar 12 foo 15 foo bar 18 foo 20 bar

Test Yourself

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

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy