Skip to content

Instantly share code, notes, and snippets.

@burkeholland
Created April 23, 2024 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burkeholland/c80e0e7cb768ba33b500e7c18e3eaecc to your computer and use it in GitHub Desktop.
Save burkeholland/c80e0e7cb768ba33b500e7c18e3eaecc to your computer and use it in GitHub Desktop.
fizz-buz
#include <iostream>
int main() {
int myArray[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
for (int i = 0; i < 15; i++) {
if (myArray[i] % 3 == 0 && myArray[i] % 5 == 0) {
std::cout << "FizzBuzz" << std::endl;
}
else if (myArray[i] % 3 == 0) {
std::cout << "Fizz" << std::endl;
}
else if (myArray[i] % 5 == 0) {
std::cout << "Buzz" << std::endl;
}
else {
std::cout << myArray[i] << std::endl;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment