We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 558d524 + be31e54 commit 1c8a7abCopy full SHA for 1c8a7ab
1 file changed
fizz_buzz.cpp
@@ -0,0 +1,21 @@
1
+#include <iostream>
2
+
3
+using namespace std;
4
5
+int main() {
6
7
+ // Begin our main loop of 1-50
8
+ for (int i = 1; i <= 50; i++) {
9
10
+ string output = "";
11
12
+ if (i % 3 == 0) output += "Fizz"; // If our current number is a multiple of 3, add "Fizz to the output"
13
+ if (i % 5 == 0) output += "Buzz"; // If our current number is a multiple of 5, add "Buzz to the output"
14
15
+ 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
16
17
+ cout << output << endl; // Show the user the output
18
19
+ }
20
21
+}
0 commit comments