017_quiz2.patch 841 B

12345678910111213141516171819202122232425
  1. --- exercises/017_quiz2.zig 2023-10-03 22:15:22.122241138 +0200
  2. +++ answers/017_quiz2.zig 2023-10-05 20:04:06.919430989 +0200
  3. @@ -9,18 +9,18 @@
  4. // Let's go from 1 to 16. This has been started for you, but there
  5. // are some problems. :-(
  6. //
  7. -const std = import standard library;
  8. +const std = @import("std");
  9. -function main() void {
  10. +pub fn main() void {
  11. var i: u8 = 1;
  12. const stop_at: u8 = 16;
  13. // What kind of loop is this? A 'for' or a 'while'?
  14. - ??? (i <= stop_at) : (i += 1) {
  15. + while (i <= stop_at) : (i += 1) {
  16. if (i % 3 == 0) std.debug.print("Fizz", .{});
  17. if (i % 5 == 0) std.debug.print("Buzz", .{});
  18. if (!(i % 3 == 0) and !(i % 5 == 0)) {
  19. - std.debug.print("{}", .{???});
  20. + std.debug.print("{}", .{i});
  21. }
  22. std.debug.print(", ", .{});
  23. }