How to resolve the algorithm 99 bottles of beer step by step in the Zig programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm 99 bottles of beer step by step in the Zig programming language

Table of Contents

Problem Statement

Display the complete lyrics for the song:     99 Bottles of Beer on the Wall.

The lyrics follow this form: ... and so on, until reaching   0     (zero). Grammatical support for   1 bottle of beer   is optional. As with any puzzle, try to do it in as creative/concise/comical a way as possible (simple, obvious solutions allowed, too).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm 99 bottles of beer step by step in the Zig programming language

Source code in the zig programming language

const print = @import("std").debug.print;
pub fn main() void {
  var i: u8 = 99;
  while (i > 2) : (i-= 1) {
  print(
    \\{} bottles of beer on the wall, {} bottles of beer.
    \\Take one down and pass it around, {} bottles of beer on the wall.
    \\
    \\
   , .{i, i, i-1});
  }
  print(
    \\2 bottles of beer on the wall, 2 bottles of beer.
    \\Take one down and pass it around, 1 bottle of beer on the wall.
    \\
    \\1 bottle of beer on the wall, 1 bottle of beer.
    \\Take one down and pass it around, no more bottles of beer on the wall.
    \\
    \\No more bottles of beer on the wall, no more bottles of beer.
    \\Go to the store and buy some more, 99 bottles of beer on the wall.
  , .{});
}

  

You may also check:How to resolve the algorithm Averages/Pythagorean means step by step in the PostScript programming language
You may also check:How to resolve the algorithm Roman numerals/Decode step by step in the Modula-2 programming language
You may also check:How to resolve the algorithm N'th step by step in the 68000 Assembly programming language
You may also check:How to resolve the algorithm Zero to the zero power step by step in the Sinclair ZX81 BASIC programming language
You may also check:How to resolve the algorithm Soundex step by step in the TXR programming language