codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <cstdlib> #include <stdio.h> using namespace std; void fizzBuzz() { // iterate over integers 1 to 100 inclusive. // print 1 line for each integer // if the integer is divisible by 3, print Fizz // if the integer is divisible by 5, print Buzz // if the integer is divisible by 15, print FizzBuzz // for all other integers, just print the number for (int i = 1; i <= 100; i++) { if (i % 15 == 0) cout << "FizzBuzz" << endl; else if (i % 3 == 0) cout << "Fizz" << endl; else if (i % 5 == 0) cout << "Buzz" << endl; else cout << i << endl; } } int main(int argc, const char** argv) { fizzBuzz(); return 0; }
Private
[
?
]
Run code
Submit