Temperature Converter - Zig Typing CST Test
Loading…
Temperature Converter — Zig Code
Converts Celsius to Fahrenheit and Fahrenheit to Celsius.
const std = @import("std");
fn cToF(c: f64) f64 { return c * 9.0 / 5.0 + 32.0; }
fn fToC(f: f64) f64 { return (f - 32.0) * 5.0 / 9.0; }
pub fn main() void {
std.debug.print("25°C = {f}°F\n", .{cToF(25.0)});
std.debug.print("77°F = {f}°C\n", .{fToC(77.0)});
}Zig Language Guide
Zig is a general-purpose, statically typed, compiled programming language designed for robustness, optimal performance, and simplicity. It emphasizes manual memory management, safety features, cross-compilation, and direct interoperability with C, making it ideal for system programming, embedded development, and high-performance applications.
Primary Use Cases
- ▸System programming and OS development
- ▸Embedded and bare-metal applications
- ▸High-performance libraries and tools
- ▸Cross-platform and cross-compiler projects
- ▸Interfacing with C libraries and APIs
Notable Features
- ▸Manual memory management with safety
- ▸Comptime (compile-time) execution
- ▸Direct C interoperability
- ▸Error unions and optional types
- ▸Cross-compilation built-in
Origin & Creator
Created by Andrew Kelley in 2015 with the goal of replacing C while providing safer and more readable system programming constructs.
Industrial Note
Zig is gaining traction in system-level programming, embedded device firmware, WebAssembly development, game engine tooling, and low-level networking applications.