-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9-fizz_buzz.c
59 lines (52 loc) · 837 Bytes
/
9-fizz_buzz.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "main.h"
#include <stdio.h>
void fizz_buzz(void);
/**
* main - check the code
*
* Return: Always 0.
*/
int main(void)
{
fizz_buzz();
return (0);
}
/**
* fizz_buzz - output functon
*
* Description:'function to print prints the numbers from 1 to 100,
* followed by a new line
* 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.
* *
* Return: function has no return values
*/
void fizz_buzz(void)
{
int n;
for (n = 1; n <= 100; n++)
{
if (n % 3 == 0 && n % 5 == 0)
{
printf("FizzBuzz");
}
else if (n % 3 == 0)
{
printf("Fizz");
}
else if (n % 5 == 0)
{
printf("Buzz");
}
else
{
printf("%i", n);
}
if (n != 100)
{
printf(" ");
}
}
printf("\n");
}