Exerpad
🔥 0
0 XP
Exercise 5 · Chapter: Tuples & StructsRequired+50 XP

Rectangle Struct

Define a struct called Rectangle with two fields: width (i32) and height (i32). Create a rectangle with width 8 and height 5, then print its area.

Expected output:

Area: 40

Hints:

  • Define the struct with i32 fields for width and height
  • Calculate the area by multiplying rect.width * rect.height
rust
fn main() {
}
Output
Run your code to see the output here.