Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: basic math operations

  • Write a Rust program that accepts two parameters on the command line and prints out the results of the 4 basic mathc operations (+, -, /, *)
cargo run 10 2
10 + 2 = 12
10 * 2 = 20
10 - 2 = 8
10 / 2 = 5