Skip to content

Commit 251a720

Browse files
imkakaMadhavBahl
authored andcommitted
C# Day1 (#13)
1 parent 6fb74c0 commit 251a720

File tree

2 files changed

+73
-8
lines changed

2 files changed

+73
-8
lines changed

Diff for: Day1/C#/FizzBuzz.cs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @author: imkaka
3+
* @date: 20/12/2018
4+
*/
5+
6+
using System;
7+
8+
public class FizzBuzz{
9+
10+
public static void Main(string[] args){
11+
12+
Console.WriteLine("/*====== Fizz Buzz ======*/");
13+
14+
Console.WriteLine("Enter a Number : ");
15+
int input = Convert.ToInt32(Console.ReadLine());
16+
17+
for(int i=1; i <= input; ++i){
18+
19+
string res = "";
20+
21+
if(i % 3 == 0) res += "Fizz";
22+
if(i % 5 == 0) res += "Buzz";
23+
24+
if(res == "") res = i.ToString();
25+
26+
Console.WriteLine(res);
27+
}
28+
}
29+
}

Diff for: Day1/README.md

+44-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fizzbuzz (17);
5151
*/
5252

5353
// Step 1: Run a loop from 1 to n, for reach iteration (i) perform the next steps
54-
// Step 2: Declare a temporary empty string (inside loop, say output)
54+
// Step 2: Declare a temporary empty string (inside loop, say output)
5555
// Step 3: If i is divisible by 3, append Fizz to the output.
5656
// Step 4: If i is divisible by 5, append Buzz to the output.
5757
// Step 5: If output is still an empty string, set it equal to i
@@ -65,7 +65,7 @@ function fizzbuzz (num) {
6565
if (i%5 === 0) opStr += 'Buzz';
6666

6767
if (opStr === '') opStr = i;
68-
68+
6969
console.log (opStr);
7070
}
7171
}
@@ -82,7 +82,7 @@ fizzbuzz (17);
8282
* @author: MadhavBahlMD
8383
* @date: 20/12/2018
8484
*/
85-
85+
8686
import java.util.Scanner;
8787

8888
public class Fizzbuzz {
@@ -113,7 +113,7 @@ public class Fizzbuzz {
113113

114114
```c
115115
/**
116-
* @author: Rajdeep Roy Chowdhury<[email protected]>
116+
* @author: Rajdeep Roy Chowdhury<[email protected]>
117117
* @github: https://github.com/razdeep
118118
* @date: 20/12/2018
119119
**/
@@ -154,7 +154,7 @@ int main()
154154

155155
```c
156156
'''
157-
* @author: Hrishi Patel <[email protected]>
157+
* @author: Hrishi Patel <[email protected]>
158158
* @github: https://github.com/hrishi1999
159159
* @date: 20/12/2018
160160
'''
@@ -178,7 +178,7 @@ for i in range(1, n):
178178
179179
```c
180180
'''
181-
* @author: Deepak Sharma
181+
* @author: Deepak Sharma
182182
* @github: https://github.com/dsdsharma
183183
* @date: 20/12/2018
184184
'''
@@ -202,9 +202,45 @@ int main()
202202
}else{
203203
cout << i << " ";
204204
}
205-
205+
206206
}
207-
207+
208208
return 0;
209209
}
210210
```
211+
212+
### [C# Solution](./C#/FizzBuzz.cs)
213+
214+
```cs
215+
/**
216+
* @author imkaka
217+
* @date 20/12/2018
218+
*/
219+
220+
221+
using System;
222+
223+
public class FizzBuzz{
224+
225+
public static void Main(string[] args){
226+
227+
Console.WriteLine("/*====== Fizz Buzz ======*/");
228+
229+
Console.WriteLine("Enter a Number : ");
230+
int input = Convert.ToInt32(Console.ReadLine());
231+
232+
for(int i=1; i <= input; ++i){
233+
234+
string res = "";
235+
236+
if(i % 3 == 0) res += "Fizz";
237+
if(i % 5 == 0) res += "Buzz";
238+
239+
if(res == "") res = i.ToString();
240+
241+
Console.WriteLine(res);
242+
}
243+
}
244+
}
245+
246+
```

0 commit comments

Comments
 (0)