Zig[lings] (0.16.0)

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/25

flashcard set

Earn XP

Description and Tags

Beginner Zig (0.15.1) programming language + Zigbash flashcards.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

26 Terms

1
New cards

To run a Zig file, you must run the command—

zig build

2
New cards

To run a Zig file with debugging purposes, not focused on output, you must run the command—

zig test

3
New cards

Zig functions are, by default, are—

Private

4
New cards

The main() function should usually be—

Public

5
New cards

A function is made public with the pub statement

True

6
New cards

pub fn foo() void {
  ...
}

This example function is made—

Public

7
New cards

Returns a value which represents imported code—

const foo = @import("foo")

8
New cards

Imports must be declared as ________ because they can only be used at _______ time rather than ___ time.

constants, compile, run

9
New cards

_____ values cannot change.

const

10
New cards

_ types are “unsigned“ and cannot store negative values.

u

11
New cards

_ means the type is 8 bits in size.

8

12
New cards

const foo: u8 = 20;
var bar: u8 = 20;

Can foo change? Why?

No, because it is a constant.

13
New cards

const foo: u8 = 20;
var bar: u8 = 20;

Can bar change? Why?

Yes, because it is a variable.

14
New cards

const foo: u8 = 20;
const bar: i8 = -20;

foo can be negative?

False

15
New cards

const foo: u8 = 20;
var bar: i8 = 20;

foo can hold 0 to 255 or -128 to 127?

0 to 127.

16
New cards

const foo: u8 = 20;
var bar: i8 = 20;

bar can be negative?

True

17
New cards

const foo: u8 = 20;
var bar: i8 = 20;

bar can hold 0 to 255 or -128 to 127?

-128 to 127

18
New cards

const foo: u8 = 20;
const bar: u16 = 2000;

foo can hold _ bits; 0 to ___

8; 255

19
New cards

const foo: u8 = 20;
const bar: u16 = 2000;

bar can hold _ bits; 0 to _____

16; 65535

20
New cards

The print function takes _ parameters.

2

21
New cards

The first parameter of the print function is a ______.

string

22
New cards

Should there be outside information, the second parameter of the print function is an _________ ____ _______.

anonymous list literal

23
New cards

var n: u8 = 50;

const pi: u32 = 314159;

const negative_eleven: i8 = -11;


std.debug.print("{} {} {}\n", .{n, pi, negative_eleven});

Assume this is the main function and all necessary imports are called. What is printed?

55 314159 -11

24
New cards

var foo: ?????? = [3]u32{ 42, 108, 5423};

Fill in the array.

[3]u32

25
New cards

When Zig can infer the size of the array, you can use _ for the size. You can also let Zig infer the ___ __ _____ so the declaration is much less verbose.

_; type of value

26
New cards