Last active
December 10, 2015 22:28
-
-
Save Pharylon/4502183 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
for (int i = 0; i <= 100; i++) | |
{ | |
bool fizz = fizzCheck(i); | |
bool buzz = buzzCheck(i); | |
if (fizz == true && buzz == true) | |
Console.WriteLine("FizzBuzz"); | |
else if (fizz == true) | |
Console.WriteLine("Fizz"); | |
else if (buzz == true) | |
Console.WriteLine("Buzz"); | |
else | |
Console.WriteLine(i); | |
} | |
Console.ReadKey(); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine("Whoops!"); | |
Console.WriteLine(ex.Message); | |
} | |
} | |
private static bool fizzCheck(int i) | |
{ | |
bool fizz = false; | |
if (i % 3 == 0) | |
fizz = true; | |
return fizz; | |
} | |
private static bool buzzCheck(int i) | |
{ | |
{ | |
bool buzz = false; | |
if (i % 5 == 0) | |
buzz = true; | |
return buzz; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the feedback. I definitely take comfort in that. I'm only halfway through my book, "Visual C# Step by Step," leaning it as my first programming language. I wouldn't even think of actually trying to get hired to write code at this point, but hopefully that day will come at some point. :)
BTW, I didn't even realize I could return bools like you did in your example. Thanks!