codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> using namespace std; int main() { //iterating from 1 to 100 for (int i = 1; i <= 100; i++) { if (i % 3 == 0 && i % 5 == 0) //if divisible by both 3 and 5 cout << "FizzBuzz\n"; else if (i % 3 == 0) //if divisible by only 3 cout << "Fizz\n"; else if (i % 5 == 0) //if divisible by only 5 cout << "Buzz\n"; else //if divisible by neither 3 nor 5 cout << i << "\n"; } }
Private
[
?
]
Run code
Submit