From the course: Debugging in C#
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Basic code challenge: Solution
(upbeat music) - [Woman] In this challenge, we have a program that attempts to print the numbers one through a hundred with some exceptions. For multiples of three, the program prints 'fizz' instead of the number. And for multiples of five, it prints 'buzz'. For numbers which are multiples of both three and five, it prints 'fizzbuzz.' Let's debug it. The first thing we're going to do is run the program to see what the actual output is, and if we can even run it. Dragging this up, we can see the contents of what the program outputted, so for zero, we get 'fizz,' for three we get 'fizz,' for five we get 'buzz,' and this is good because here, if it's a multiple of three, we want to print 'fizz.' And, if it's a multiple of five, we do want to print 'buzz.' Now, for that multiple of fifteen, we print 'fizz,' we don't print 'fizzbuzz.' And if we scroll down to thirty, we again print 'fizz,' instead of 'fizzbuzz.' And this is what we should be printing. To see what's going on with our…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.