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

Greeting

Create a function called greet that takes a name (&str) and prints a personalized greeting. Call it for three different names.

Expected output:

Hello, Alice!
Hello, Bob!
Hello, Charlie!

Hints:

  • Define with fn greet(name: &str)
  • Inside, use println!("Hello, {}!", name);
  • Call it three times with different names
rust
fn main() {
}
Output
Run your code to see the output here.