Skip to content

Instantly share code, notes, and snippets.

@eprislac
Created February 23, 2019 23:48
Show Gist options
  • Save eprislac/c69c39904ef8c741a6866ccb9e9de8e6 to your computer and use it in GitHub Desktop.
Save eprislac/c69c39904ef8c741a6866ccb9e9de8e6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
string fizzbuzziness(int num) {
string fizz = num % 3 == 0 ? "Fizz" : "";
string buzz = num % 5 == 0 ? "Buzz" : "";
string initString = "";
ostringstream retVal;
retVal << initString << fizz << buzz;
return retVal.str();
}
int main() {
int num;
cout << "Please input a whole-number value:" << endl;
cin >> num;
cout << fizzbuzziness(num) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment