Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fizz_buzz.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>

using namespace std;

int main() {

// Begin our main loop of 1-50
for (int i = 1; i <= 50; i++) {

string output = "";

if (i % 3 == 0) output += "Fizz"; // If our current number is a multiple of 3, add "Fizz to the output"
if (i % 5 == 0) output += "Buzz"; // If our current number is a multiple of 5, add "Buzz to the output"

if (output == "") output = to_string(i); // If the output is empty (our number isn't a multiple of 3 or 5), we simply set it to our number

cout << output << endl; // Show the user the output

}

}