03_assignment.zig 1.0 KB

123456789101112131415161718192021222324252627282930
  1. //
  2. // Oh dear! It seems we got a little carried away making const u8 values.
  3. // * const means constant (cannot be changed)
  4. // * u8 means unsigned (cannot be negative), 8-bit integer
  5. //
  6. // Hint 1: Use 'var' for values that can change.
  7. // Hint 2: Use enough bits to hold the value you want:
  8. // u8 255
  9. // u16 65,535
  10. // u32 4,294,967,295
  11. // Hint 3: Use 'i' (e.g. 'i8', 'i16') for signed integers.
  12. //
  13. const std = @import("std");
  14. pub fn main() void {
  15. const n: u8 = 50;
  16. n = n + 5;
  17. const pi: u8 = 314159;
  18. const negative_eleven: u8 = -11;
  19. // There are no errors in the next line, just explanation:
  20. // Perhaps you noticed before that the print function takes two
  21. // parameters. Now it will make more sense: the first parameter
  22. // is a string. The string may contain placeholders '{}', and the
  23. // second parameter is an anonymous struct (data structure)
  24. // with values to be printed in place of the placeholders.
  25. std.debug.print("{} {} {}\n", .{n, pi, negative_eleven});
  26. }