સોર્સ ફાઇલો ગોઠવવી
કિંમતની ગણતરી તેની પોતાની ફાઇલમાં મૂકો. મુખ્ય કાર્યક્રમ તે કાર્યને કહે છે. ઉદાહરણ ચલાવતા પહેલા બંને ફાઇલોને એક જ ફોલ્ડરમાં સાચવો.
એક સરળ ઉદાહરણ
ફંક્શનને બીજી ફાઇલમાં કૉલ કરો.
શરૂઆતમાં2 × 3
પરિણામ6
pub fn total(units: i64, price: i64) i64 { return units * price; }
const std = @import("std");
const prices = @import("prices.zig");
pub fn main() !void {
std.debug.print("{any}\n", .{prices.total(2, 3)});
}
6
જાહેરાતો
રોજિંદા જીવનનાં ઉદાહરણો
એક નાસ્તાની દુકાન બે-બે સિક્કા પર પાંચ જ્યુસ વેચે છે. બાકી રકમ છાપવા માટે વહેંચાયેલ કિંમત કાર્યનો ઉપયોગ કરો.
શરૂઆતમાં5 juices × 2
પરિણામ10
pub fn total(units: i64, price: i64) i64 { return units * price; }
const std = @import("std");
const prices = @import("prices.zig");
pub fn main() !void {
std.debug.print("{any}\n", .{prices.total(5, 2)});
}
10