Curriculum Basics Functions exercise 2 · mcq
Functions
Zig's functions are PRIVATE by default — the pub keyword opts
in to public visibility (callable from other modules). main is
always pub fn because the runtime calls it. Pick the
declaration for a function that's part of this module's public
API.
TypeScript reference
About this theme
Zig functions look like TS with the type annotations shifted: fn name(param: Type) ReturnType { ... }. Visibility is opt-in via pub fn — top-level functions are private by default. Zig has no tuple-return; multi-return uses a struct (the Zig idiom) or out-params. Function-level errors come later in the errors module; here we focus on the value-returning shape.