# Rust program to calculate the area of the rectangle

Input the length and breadth, find the area of the rectangle using Rust program.
Submitted by Nidhi, on September 26, 2021

Problem Solution:

Here, we will read the value of length and breadth from the user and calculate the area of the rectangle.

Program/Source Code:

The source code to calculate the area of the rectangle is given below. The given program is compiled and executed successfully.

```// Rust program to calculate the
// area of rectangle

use std::io;

fn main() {
let mut length:f32 = 0.0;
let mut area:f32 = 0.0;

let mut input1 = String::new();
let mut input2 = String::new();

println!("Enter length: ");
length = input1.trim().parse().expect("Not a valid number");

breadth = input2.trim().parse().expect("Not a valid number");

println!("Area of rectangle: {}",area);
}
```

Output:

```RUN 1:
Enter length:
5.7
3.4
Area of rectangle: 19.38

RUN 2:
Enter length:
10
20
Area of rectangle: 200

RUN 3:
Enter length:
10.5
5.10
Area of rectangle: 53.55
```

Explanation:

Here, we read the value of length and breadth from the user and calculated the area of the rectangle. After that, we printed the result.