← Back
Code Challenge 12 - FizzBuzz
Introduction
FizzBuzz is a classic elementary programming challenge. The program outputs 100 statements, starting from the number one and ending with 100. However, there’s a twist. Instead of outputting the numbers 1 through 100, certain numbers are replaced with words. Numbers divisible by 3 output the word ‘fizz’ instead of the number, numbers divisible by 5 output ‘buzz’, and numbers divisible by 3 and 5 output the word ‘fizzbuzz’.
Skills to Practice
- Repeating statements using loops
- Making decisions using if statements
- Checking for divisibility
Challenge Tasks
- Create a console project named CodeChallenge12FizzBuzz.
- Begin by outputting the numbers 1 through 100 using a loop of your choice.
- However, if the current number is divisible by 3, instead output the word ‘Fizz’.
- Or, if the current number is divisible by 5, instead output the word ‘Buzz’.
- Finally, if the current number is divisible by 3 and 5, instead output the word ‘FizzBuzz’.
Sample Output