Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 618 Bytes

printing_numbers.md

File metadata and controls

48 lines (34 loc) · 618 Bytes

Printing Numbers

In addition to strings, we can also print numbers that are specified by {}. For example:

fn main() {
    println!("{}", 123);
}

Output:

123

The numbers can be replaced with arithmetic expressions.

fn main() {
    println!("{}", 2 + 4 * 3);
}

Output:

14

The expressions can be combined with a formatted text.

fn main() {
    println!("{} x {} = {}", 14, 9, 14 * 9);
}

Output:

14 x 9 = 126

➡️ Next: Declaring Variables

📘 Back: Table of contents