Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Rectangle Area Function

Create a function called rectangle_area that takes a width and height (both i32) and returns the area. Use it to calculate and print the areas of two different rectangles.

Expected output:

text
A 3x4 rectangle has area 12
A 10x5 rectangle has area 50

Hints:

  • Define with fn rectangle_area(width: i32, height: i32) -> i32
  • Return width * height
  • Use println!("A {}x{} rectangle has area {}", 3, 4, rectangle_area(3, 4));
rust
fn main() {
}