Skip to content

Latest commit

 

History

History
41 lines (27 loc) · 949 Bytes

README.md

File metadata and controls

41 lines (27 loc) · 949 Bytes

episode-006

Where we do some calculations

Setup

We need to prepare the following

  • A Rust project with the name calculations
  • Editor with the project open

Script

Historically computers where people that would do calculations. We honor that tradition by making a Rust program that does some calculations

The println! macro als nows how to print numbers. Here the program prints 42

println!("The answer: {}", 42);

We will use it to explore the answers of various calculations. For example

println!("What is 6 times 7: {}", 6 * 7);

or

println!("What is 17 + 25: {}", 17 + 25);

In case you are wondering if Rust knows about rules of mathematics

println("What is 17 + 5 * 5: {}", 17 + 5 * 5);

Rust adheres to familiar precedence rules.

And there you have it, we did some calculations.