Skip to content

Instantly share code, notes, and snippets.

@Souzooka
Created March 25, 2017 00:41
Show Gist options
  • Select an option

  • Save Souzooka/79ca41cddd6b59a45d0bad978ff1d497 to your computer and use it in GitHub Desktop.

Select an option

Save Souzooka/79ca41cddd6b59a45d0bad978ff1d497 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void fizzBuzz(int range)
{
for (int i = 1; i <= range; i++)
{
cout << i << ": ";
if (i % 3 == 0 && i % 5 == 0)
{
cout << "Fizz Buzz" << endl;
}
else if (i % 3 == 0)
{
cout << "Fizz" << endl;
}
else if (i % 5 == 0)
{
cout << "Buzz" << endl;
}
else
{
cout << endl;
}
}
}
int main()
{
int range;
cin >> range;
fizzBuzz(range);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment