diff options
author | Martin Ashby <martin@ashbysoft.com> | 2022-12-09 22:07:01 +0000 |
---|---|---|
committer | Martin Ashby <martin@ashbysoft.com> | 2022-12-09 22:07:01 +0000 |
commit | 0e447c7956410a993614f9337d6219e017722443 (patch) | |
tree | c12780891cbbd14b52695df1fe336cc8981de6d9 /exercises/020_quiz3.zig | |
parent | bb5b8f115a57fc8c85ac7344fe4dc0b796e32487 (diff) | |
download | ziglings-0e447c7956410a993614f9337d6219e017722443.tar.gz ziglings-0e447c7956410a993614f9337d6219e017722443.tar.bz2 ziglings-0e447c7956410a993614f9337d6219e017722443.tar.xz ziglings-0e447c7956410a993614f9337d6219e017722443.zip |
001-024 complete
Diffstat (limited to 'exercises/020_quiz3.zig')
-rw-r--r-- | exercises/020_quiz3.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/exercises/020_quiz3.zig b/exercises/020_quiz3.zig index 651af8c..267c991 100644 --- a/exercises/020_quiz3.zig +++ b/exercises/020_quiz3.zig @@ -21,8 +21,8 @@ pub fn main() void { // // This function prints, but does not return anything. // -fn printPowersOfTwo(numbers: [4]u16) ??? { - loop (numbers) |n| { +fn printPowersOfTwo(numbers: [4]u16) void { + for (numbers) |n| { std.debug.print("{} ", .{twoToThe(n)}); } } @@ -31,13 +31,13 @@ fn printPowersOfTwo(numbers: [4]u16) ??? { // exercise. But don't be fooled! This one does the math without the aid // of the standard library! // -fn twoToThe(number: u16) ??? { +fn twoToThe(number: u16) u16 { var n: u16 = 0; var total: u16 = 1; - loop (n < number) : (n += 1) { + while (n < number) : (n += 1) { total *= 2; } - return ???; + return total; } |