Sha256: 70d2c2985c169ea65c35f903ece2046b0e360e48acccebf0bb9579726065a33a

Contents?: true

Size: 572 Bytes

Versions: 10

Compression:

Stored size: 572 Bytes

Contents

Note that this code cannot be run within the [http://play.rust-lang.org Rust playpen] as it does not support console input.
use std::env;

fn main() {
    let args: Vec<_> = env::args().collect();
    let a = args[1].parse::<i32>().unwrap();
    let b = args[2].parse::<i32>().unwrap();

    println!("sum:              {}", a + b);
    println!("difference:       {}", a - b);
    println!("product:          {}", a * b);
    println!("integer quotient: {}", a / b); // truncates towards zero
    println!("remainder:        {}", a % b); // same sign as first operand
}

Version data entries

10 entries across 7 versions & 1 rubygems

Version Path
zettacode-0.1.7 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.6 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.6 files.zettacode2/arithmetic.integer/rust.txt
zettacode-0.1.5 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.5 files.zettacode2/arithmetic.integer/rust.txt
zettacode-0.1.4 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.4 files.zettacode2/arithmetic.integer/rust.txt
zettacode-0.1.3 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.2 files.zettacode/arithmetic.integer/rust.txt
zettacode-0.1.1 zettacode.files/arithmetic.integer/rust.txt