Zig
Zig
Generating Random Integer in Range
See more PRNG Examples
Demonstrates how to generate random integers in a specified range.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main() !void {
var success: bool = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
success = false;
const fortuna = try chilkat.Prng.init();
defer fortuna.deinit();
// Generate random integers between 12 and 24 inclusive
var i: i32 = 0;
i = 0;
while (i <= 100) : (i += 1) {
std.debug.print("{d}\n", .{fortuna.randomInt(12, 24)});
}
}