Complete the code to declare a function named greet that prints a greeting.
fn [1]() { println!("Hello, world!"); }
main instead of greet.print as a function name.The function name should be greet to match the task.
Complete the code to declare a function named add that takes two i32 parameters.
fn add(a: i32, [1]: i32) -> i32 {
a + b
}The second parameter name should be b to match the function body.
Fix the error in the function declaration by completing the missing return type.
fn multiply(x: i32, y: i32) -> [1] {
x * y
}The function multiplies two i32 values, so the return type must be i32.
Fill both blanks to declare a function named is_even that takes an i32 and returns a bool.
fn [1](num: i32) -> [2] { num % 2 == 0 }
is_odd.i32.The function name is is_even and it returns a bool indicating if the number is even.
Fill all three blanks to declare a function named describe_number that takes an i32 and returns a String.
fn [1](n: [2]) -> [3] { if n > 0 { String::from("Positive") } else { String::from("Non-positive") } }
number_desc.The function is named describe_number, takes an i32, and returns a String.
