Skip to content

bits-of-rust/episode-006

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Where we do some calculations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages