Exerpad
🔥 0
0 XP
Exercise 2 · Chapter: FunctionsRequired+50 XP

Add Numbers

Create a function called add that takes two i32 parameters and returns their sum. Then call it from main and print the result.

Expected output:

3 + 5 = 8

Hints:

  • Define with fn add(a: i32, b: i32) -> i32
  • The last expression without a semicolon is the return value: a + b
  • In main, use println!("3 + 5 = {}", add(3, 5));
rust
fn main() {
}
Output
Run your code to see the output here.