Skip to content

Instantly share code, notes, and snippets.

@ArtBears
Created May 10, 2013 20:02
Show Gist options
  • Save ArtBears/5556991 to your computer and use it in GitHub Desktop.
Save ArtBears/5556991 to your computer and use it in GitHub Desktop.
The c++ version of the FizzBuzz problem.
#include <iostream>
using namespace std;
int main() {
int a(1);
for(int i = 1; i < 101; i++)
{
a = i;
if(a % 3 == 0 && a % 5 == 0)
{
cout << "fizzbuzz" << endl;
}
else if(a % 5 == 0)
{
cout << "buzz" << endl;
}
else if(a % 3 == 0)
{
cout << "fizz" << endl;
}
else
{
cout << a << endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment