Skip to content

Commit 102cdab

Browse files
author
mpj
authored
Create fizz.c
1 parent cd6d176 commit 102cdab

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

fizz.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Fizz.c is a program that prints the numbers from 1 to 100.
2+
// But for multiples of three print “Fizz” instead of the number
3+
// and for the multiples of five print “Buzz”.
4+
// For numbers which are multiples of both three and five print “FizzBuzz”.
5+
// Problem source: https://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
6+
7+
#include <stdio.h>
8+
9+
int main(void)
10+
{
11+
for (int i = 0; i < 100; i++)
12+
{
13+
if (i % 3 == 0 && i % 5 == 0)
14+
{
15+
printf("FizzBuzz\n");
16+
}
17+
18+
if (i % 3 == 0)
19+
{
20+
printf("Fizz\n");
21+
}
22+
23+
if (i % 5 == 0)
24+
{
25+
printf("Buzz\n");
26+
}
27+
28+
else
29+
{
30+
printf("%i\n",i);
31+
}
32+
}
33+
34+
return 0;
35+
}

0 commit comments

Comments
 (0)