FizzBuzz: Difference between revisions
Content added Content deleted
(→{{header|C++}}: <istream.h> is a non-standard header, and <istream> doesn't contain cout anyway; also added syntax highlighting) |
(→{{header|C++}}: Alternate version not using modulo 15) |
||
Line 132: | Line 132: | ||
} |
} |
||
return 0; |
return 0; |
||
} |
|||
</cpp> |
|||
Alternate version not using modulo 15: |
|||
<cpp> |
|||
#include <iostream> |
|||
int main() |
|||
{ |
|||
for (int i = 0; i <= 100; ++i) |
|||
{ |
|||
bool fizz = !(i % 3); |
|||
bool buzz = !(i % 5); |
|||
if (fizz) |
|||
std::cout << "Fizz"; |
|||
if (buzz) |
|||
std::cout << "Buzz"; |
|||
if (!fizz && !buzz) |
|||
std::cout << i; |
|||
std::cout << std::endl; |
|||
} |
|||
} |
} |
||
</cpp> |
</cpp> |