Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Square Number

Create a function called square that takes an i32 and returns that number multiplied by itself. Print the square of 4 and the square of 9.

Expected output:

text
4 squared is 16
9 squared is 81

Hints:

  • Define with fn square(n: i32) -> i32
  • Return n * n (no semicolon!)
  • Use println!("{} squared is {}", 4, square(4));
rust
fn main() {
}