diff --git a/Day1/C/fizzbuzz2.c b/Day1/C/fizzbuzz2.c new file mode 100644 index 00000000..7aa89de3 --- /dev/null +++ b/Day1/C/fizzbuzz2.c @@ -0,0 +1,29 @@ +/* + * @author: shashanknenar + * @date: 01/10/2020 +*/ + + +#include + +int main(void) +{ + int i; + for (i=1; i<=100; i++) + { + + if (i%15 == 0) + printf ("FizzBuzz\t"); + + else if ((i%3) == 0) + printf("Fizz\t"); + + else if ((i%5) == 0) + printf("Buzz\t"); + + else + printf("%d\t", i); //print + } + + return 0; +} \ No newline at end of file diff --git a/Day1/README.md b/Day1/README.md index f022d3d8..5dbc547a 100644 --- a/Day1/README.md +++ b/Day1/README.md @@ -149,6 +149,40 @@ int main() return 0; } ``` +### [fizzbuzz2.c](./C/fizzbuzz2.c) + +```c +/* + * @author: shashanknenar + * @github: https://github.com/shashanknenar + * @date: 01/10/2020 +*/ + +#include + +int main(void) +{ + int i; + for (i=1; i<=100; i++) + { + + if (i%15 == 0) + printf ("FizzBuzz\t"); + + else if ((i%3) == 0) + printf("Fizz\t"); + + else if ((i%5) == 0) + printf("Buzz\t"); + + else + printf("%d\t", i); //print + } + + return 0; +} +``` + ## Python(3) Implementation @@ -490,4 +524,4 @@ obj.solveFizzBuzzProblem(17); The beauty of programming lies in the fact that there is never a single solution to any problem. -In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :) \ No newline at end of file +In case you have an alternative way to solve this problem, do contribute to this repository (https://github.com/CodeToExpress/dailycodebase) :)