Skip to content

Instantly share code, notes, and snippets.

@Pharylon
Last active December 10, 2015 22:28
Show Gist options
  • Save Pharylon/4502183 to your computer and use it in GitHub Desktop.
Save Pharylon/4502183 to your computer and use it in GitHub Desktop.
FizzBuzz
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;
}
}
}
}
@Pharylon
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment