diff --git a/Day1/C/fizzbuzzy.c b/Day1/C/fizzbuzzy.c new file mode 100644 index 00000000..202e1f5b --- /dev/null +++ b/Day1/C/fizzbuzzy.c @@ -0,0 +1,24 @@ +/* + * @author: anonymousksr + * @date: 01/10/2020 +*/ +#include + +int main(void) +{ + int i; + for(i=1; i<=100; i++) + { + if(((i%3)||(i%5))== 0) + printf("number= %d FizzBuzz\n", i); + else if((i%3)==0) + printf("number= %d Fizz\n", i); + else if((i%5)==0) + printf("number= %d Buzz\n", i); + else + printf("number= %d\n",i); + + } + + return 0; +} \ No newline at end of file diff --git a/Day1/README.md b/Day1/README.md index bf8b6608..fefcb1d3 100644 --- a/Day1/README.md +++ b/Day1/README.md @@ -122,34 +122,27 @@ public class Fizzbuzz { #include -int main() +int main(void) { - int n; - printf("Enter a number upto which you want to find Fizzbuzz numbers "); - scanf("%d", &n); - for (int i = 1; i <= n; i++) + int i; + for(i=1; i<=100; i++) { - if (i % 5 == 0 && i % 3 == 0) - { - printf("FizzBuzz\n"); - } - else if (i % 5 == 0) - { - printf("Buzz\n"); - } - else if (i % 3 == 0) - { - printf("Fizz\n"); - } + if(((i%3)||(i%5))== 0) + printf("number= %d FizzBuzz\n", i); + else if((i%3)==0) + printf("number= %d Fizz\n", i); + else if((i%5)==0) + printf("number= %d Buzz\n", i); else - { - printf("%d\n", i); - } + printf("number= %d\n",i); + } + return 0; } ``` + ## Python(3) Implementation ### [fizzbuzz.py](./Python3/fizzbuzz.py) @@ -256,6 +249,8 @@ int main() } ``` + + ### [C# Solution](./C#/FizzBuzz.cs) ```cs @@ -410,4 +405,4 @@ for ($i=1; $i <= $num; $i++) { 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) :)