The Fizz Buzz is a classic developer interview question that is asked or referred to so often for so long, it is almost a cliché!. This training project, prepared by Codecademy.
Write a fizzbuzz.cpp program that outputs numbers from 1 to 100.
But for multiples of 3, print Fizz instead of the number and for the multiples of 5, print Buzz. For numbers which are multiples of both 3 and 5 print, FizzBuzz.
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
...
97
98
Fizz
Buzz
Happy coding!
- C++
How to compile and execute:
- Download
sortinghat.cpp
. - Open command line interface and navigate to the directory where the files are downloaded.
- Run the following commands to compile and execute the program:
g++ fizzbuzz.cpp -o fizzbuzz
./fizzbuzz