How to find the Division of Two Numbers in Rust - Step by Step Examples



How to find the Division of Two Numbers in Rust ?

Answer

To divide two numbers in Rust, you can use the '/' operator.

How to find the Division of Two Numbers in rust language

✐ Examples

1 Division of Two Numbers

In this example,

  1. We declare variables numerator and denominator and assign values to them.
  2. We perform the division operation using the / operator and print the result.

Rust Program

fn main() {
    let numerator = 20;
    let denominator = 5;
    let quotient = numerator as f64 / denominator as f64;
    println!("Division of {} by {} is: {}", numerator, denominator, quotient);
}

Output

Division of 20 by 5 is: 4

Summary

In this tutorial, we learned How to find the Division of Two Numbers in Rust language with well detailed examples.




More Rust Arithmetic Operations Tutorials

  1. How to Add Two Numbers in Rust ?
  2. How to find the Subtraction of Two Numbers in Rust ?
  3. How to Multiply Two Numbers in Rust ?
  4. How to find the Division of Two Numbers in Rust ?
  5. How to find Average of Two Numbers in Rust ?
  6. How to find Average of Three Numbers in Rust ?