Created
February 23, 2019 23:48
-
-
Save eprislac/c69c39904ef8c741a6866ccb9e9de8e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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