Calculate a total
Multiply the number of items by the price of one item to get the total.
Simple example
Start2 × 3
Result6
const std = @import("std");
fn show(value: i64) !void {
var buffer: [64]u8 = undefined;
var writer = std.fs.File.stdout().writer(&buffer);
try writer.interface.print("{d}\n", .{value});
try writer.interface.flush();
}
pub fn main() !void {
try show((2 * 3));
}
6
Advertisements
Everyday examples
Three notebooks cost 4 each. What is the total?
Start3 × 4
Result12
const std = @import("std");
fn show(value: i64) !void {
var buffer: [64]u8 = undefined;
var writer = std.fs.File.stdout().writer(&buffer);
try writer.interface.print("{d}\n", .{value});
try writer.interface.flush();
}
pub fn main() !void {
const notebooks: i64 = 3;
const price: i64 = 4;
try show((notebooks * price));
}
12