Created
June 25, 2019 18:33
-
-
Save Edmundworks/ab674fa542b63049ac63cd757835fc21 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
// Program prints numbers 1-100 | |
// For multiples of 3 print Fizz | |
// For multiples of 5 print buzz | |
// For multiples of BOTH print FizzBuzz | |
// Make an array of ints | |
// Make a for loop that prints the ith int in the array up until i = 100 | |
// Add if array[i] % 3 != 0 then print buzz | |
// Add same for % 5 | |
// Add for both | |
int array[100]; | |
// Fill up array with numbers 1-100 | |
int main(void) | |
{ | |
for (int = 1; i <101; i++) | |
{ | |
array[i] = i; | |
} | |
// Check if divisible by 3 and 5, just one or neither and print | |
for (int = 1; i <101; i++) | |
{ | |
if (array[i] % 3 == 0 && array[i] % 5 == 0) | |
{ | |
printf("FizzBuzz\n"); | |
} | |
else if (array[i] % 3 == 0) | |
{ | |
printf("Fizz\n"); | |
} | |
else if (array[i] % 5 == 0); | |
{ | |
printf("Buzz\n"); | |
} | |
else | |
{ | |
printf("%i\n", array[i]); | |
} | |
} | |
} | |
// Started at 2:08 ended at 2:33 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment