From 55ad7c32f2d534b1fbd438204d21738f958c51a5 Mon Sep 17 00:00:00 2001 From: Dave Gauer Date: Tue, 9 Feb 2021 18:36:57 -0500 Subject: Moved exercises to exercises because exercises --- exercises/17_quiz2.zig | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 exercises/17_quiz2.zig (limited to 'exercises/17_quiz2.zig') diff --git a/exercises/17_quiz2.zig b/exercises/17_quiz2.zig new file mode 100644 index 0000000..339f733 --- /dev/null +++ b/exercises/17_quiz2.zig @@ -0,0 +1,28 @@ +// +// Quiz time again! Let's see if you can solve the famous "Fizz Buzz"! +// +// "Players take turns to count incrementally, replacing +// any number divisible by three with the word "fizz", +// and any number divisible by five with the word "buzz". +// - From https://en.wikipedia.org/wiki/Fizz_buzz +// +// Let's go from 1 to 16. This has been started for you, but there's +// some problems. :-( +// +const std = import standard library; + +function main() void { + var i: u8 = 1; + var stop_at: u8 = 16; + + // What kind of loop is this? A 'for' or a 'while'? + ??? (i <= stop_at) : (i += 1) { + if (i % 3 == 0) std.debug.print("Fizz", .{}); + if (i % 5 == 0) std.debug.print("Buzz", .{}); + if ( !(i % 3 == 0) and !(i % 5 == 0) ) { + std.debug.print("{}", .{???}); + } + std.debug.print(", ", .{}); + } + std.debug.print("\n",.{}); +} -- cgit v1.2.3-ZIG