Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 59 / 68

FizzBuzz (the classic exercise)

This lesson covers solving FizzBuzz in VB.NET, with the aim of combining branching and looping.

FizzBuzz prints the numbers from 1 upwards, replacing multiples of 3 with "Fizz", multiples of 5 with "Buzz", and multiples of both (that is, of 15) with "FizzBuzz". It is the classic beginner's exercise.

The sample code loops from 1 to 15 and checks i Mod 15 = 0 first so that multiples of 15 take priority, then multiples of 3 and 5. The order of the checks decides the result.

A common early stumble is exactly that order. Test 3 and 5 first and a multiple of 15 prints just "Fizz", so the strictest condition has to come first.

FizzBuzz is never used directly in practice, but as an exercise it checks whether you can put branching and looping together correctly, which is why it is such a common measure of the fundamentals.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)