forked from iamAnki/CPP-Programs-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfizz_buzz.cpp
More file actions
30 lines (24 loc) · 790 Bytes
/
fizz_buzz.cpp
File metadata and controls
30 lines (24 loc) · 790 Bytes
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
// CPP program to print Fizz Buzz
#include <stdio.h>
int main()
{
for (int i = 1; i <= 100; i++)
{
// number divisible by 3 and 5 will
// always be divisible by 15, print
// 'FizzBuzz' in place of the number
if (i%15 == 0)
printf ("FizzBuzz\t");
// number divisible by 3? print 'Fizz'
// in place of the number
else if ((i%3) == 0)
printf("Fizz\t");
// number divisible by 5, print 'Buzz'
// in place of the number
else if ((i%5) == 0)
printf("Buzz\t");
else // print the number
printf("%d\t", i);
}
return 0;
}