I am going to be posting some interview questions. So lets start with something really simple. There is a large number of people who constantly fail the fizz buzz test.
The question is simple. Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz".
The solution is also very simple.
static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
if (i % 5 == 0 && i % 3 == 0)
{
Console.WriteLine("FizzBuzz");
}
else if (i % 5 == 0)
{
Console.WriteLine("Buzz");
}
else if (i % 3 == 0)
{
Console.WriteLine("Fizz");
} else {
Console.WriteLine(i);
}
}
Console.ReadLine();
}
The above is a simple test to verify that the person taking the test has the ability to convert logic written in English to logic written in code. For some reson there are a large number of people who still fails this. Here is the list of most common failures and excuses I have seen and what I though about them at the time.
Failures
- They start the loop from 0 instead of 1
- They get the order of the the if / else if wrong. They check for the i mod 3 before checking for i mod 3 and i mod 5.
- They get the order of the if wrong. They print out BuzzFizz instead of FizzBuzz.
Excuses
The best excuse that I have heard about it is typically oh. Its the stress of a job interview. I would agree that interviews can be stressful. However so can work. The candidate has just told me that they crack under pressure and will be unable to perform in high pressure situation or when trying to fix bugs in a stress environment eg a tight deadline.
Did You find this page useful?
Yes
No