multiply two numbers in rust

In Rust, you can use the * operator to multiply two numbers. For example:

main.rs
fn main() {
    let num1 = 5;
    let num2 = 10;
    let result = num1 * num2;
    println!("The result is: {}", result);
}
124 chars
7 lines

In this example, we define two variables num1 and num2 with values 5 and 10 respectively. We then multiply these two numbers using the * operator, and store the result in a third variable called result. Finally, we print the value of result to the console.

The output of this program would be:

main.rs
The result is: 50
18 chars
2 lines

gistlibby LogSnag