1. Home
  2. /
  3. Zig-wasm
  4. /
  5. Zig WASM Even Check

Zig WASM Even Check - Zig-wasm Typing CST Test

Loading…

Zig WASM Even Check — Zig-wasm Code

Checks if a number is even and prints the result.

# zig/demo/even.zig
const std = @import("std");

pub export fn isEven(n: i32) void {
	if (n % 2 == 0) {
		std.debug.print("Even\n", .{});
	} else {
		std.debug.print("Odd\n", .{});
	}
}

Zig-wasm Language Guide

Zig is a general-purpose programming language designed for robustness, optimality, and simplicity. With Zig-Wasm, developers can compile Zig code to WebAssembly, enabling high-performance, low-level applications in the browser or other Wasm runtimes.

Primary Use Cases

  • ▸Porting system-level libraries to WebAssembly
  • ▸High-performance game engines or simulations in the browser
  • ▸Cryptography, compression, or other CPU-intensive algorithms
  • ▸Replacing C/C++ Wasm modules with safer, simpler Zig code
  • ▸Low-level WASI (WebAssembly System Interface) applications

Notable Features

  • ▸Direct compilation to WebAssembly (Wasm32 target)
  • ▸No hidden runtime or garbage collector
  • ▸C interop for leveraging existing code
  • ▸Manual memory management with safety options
  • ▸Simple, readable, and maintainable syntax

Origin & Creator

Zig is created by Andrew Kelley, with the community contributing to language development, compiler improvements, and WebAssembly support.

Industrial Note

Zig-Wasm is particularly useful for developers who need predictable, high-performance WebAssembly modules, low-level memory control, or integration with C/C++ codebases for web execution.

More Zig-wasm Typing Exercises

Simple Zig WebAssembly ProgramZig WASM Add Two NumbersZig WASM Multiply Two NumbersZig WASM FibonacciZig WASM FactorialZig WASM Maximum of Two NumbersZig WASM Minimum of Two NumbersZig WASM Toggle BooleanZig WASM Print Array

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher