Fizz Buzz problem is a famous interview question, Lets discuss this problem.
Problem Statement :
For 1-100 numbers :
if the number is divisible by 5 print – “Buzz”
if the number is divisible by 3 print – “Fizz”
if the number is divisible by both print – “Fizz Buzz”
I have a created a video tutorial :
Here is the code shown in the video :
1 2 3 4 5 6 7 8 9 |
private void FizzBuzzTest(int range) { string[,] values = new string [2,2]{ {"None","Three"}, {"Five","Both"} }; for(int i =1;i<=range;i++) string result = values[Convert.ToInt32(i % 5 == 0), Convert.ToInt32(i % 3 == 0)]; } |
Pingback: Melanie Glastrong()