-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathFizzBuzz.cs
58 lines (55 loc) · 1.6 KB
/
FizzBuzz.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication178
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("\n");
Console.WriteLine("Enter the start value:");
int k = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("\n");
Console.WriteLine("Enter the End value:");
int N = Convert.ToInt32(Console.ReadLine());
int i, s = 0;
string[] fizzbuzz = new string[N];
for ( i=k; i < N; i++)
{
if (i % 3 == 0&&i<15)
{
string three = "Fizz";
fizzbuzz[s] = three;
s++;
}
else if (i % 5 == 0&&i<15)
{
string five = "Buzz";
fizzbuzz[s] = five;
s++;
}
else if (i % 5 == 0 && i % 3 == 0 && i > 10)
{
string thrfiv = "FizzBuzz";
fizzbuzz[s] = thrfiv;
s++;
}
else
{
fizzbuzz[s] = i.ToString();
s++;
}
}
Console.WriteLine("\n");
for (s = 0; s < N; s++)
{
Console.Write("{0} ", fizzbuzz[s]);
}
Console.WriteLine("\n");
Console.ReadLine();
}
}
}