Created
October 25, 2021 13:44
-
-
Save jonathanschilling/1be302fef2ab9187be44e3f6efa17eaa to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains 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 <stdio.h> | |
// Write a program that prints the numbers from 1 to 100. | |
// But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". | |
// For numbers which are multiples of both three and five print "FizzBuzz". | |
int main(int argc, char** argv) { | |
int fb = 0; | |
for (int i=1; i<=100; ++i) { | |
fb = 0; | |
if (i%3 == 0) { | |
printf("Fizz"); | |
fb = 1; | |
} | |
if (i%5 == 0) { | |
printf("Buzz"); | |
fb = 1; | |
} | |
if (fb == 0) { | |
printf("%d", i); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment