GitHub

Practice

Practice - 005

A program to read two integers and explain arithmetic operators

use text_io::scan;
fn main() {
practice5()
}
fn practice5() {
let a: i32;
let b: i32;
println!("Enter the values of a,b: (with a space in between)");
scan!("{} {}", a, b);
println!("a + b = {}", a + b);
println!("a - b = {}", a - b);
println!("a * b = {}", a * b);
println!("a / b = {}", a / b);
}

Config

[package]
name = "practice"
version = "0.1.0"
edition = "2021"
[dependencies]
text_io = "0.1.12"

Result

Enter the values of a,b: (with a space in between)
7 2
a + b = 9
a - b = 5
a * b = 14
a / b = 3
Previous
Practice - 004