Functions are a fundamental building block in Rust, as in any programming language. They allow you to encapsulate logic and reuse code, making your programs more modular and easier to understand. In this challenge, you will define and implement a series of simple functions that perform basic operations.
Your task is to define three functions:
add(a: i32, b: i32) -> i32
- This function should return the sum of a
and b
.subtract(a: i32, b: i32) -> i32
- This function should return the difference between a
and b
.multiply(a: i32, b: i32) -> i32
- This function should return the product of a
and b
.You need to complete these functions so that they correctly perform the specified operations.
let result = add(2, 3);
assert_eq!(result, 5);
let result = subtract(5, 3);
assert_eq!(result, 2);
let result = multiply(2, 3);
assert_eq!(result, 6);
fn
keyword followed by the function name, parameters in parentheses, and the return type.return
keyword or just the last expression in the function body to return a value.pub
keyword to make your functions public so they can be accessed from other modules.pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`pub fn subtract(a: i32, b: i32) -> i32 { a - b}// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`pub fn multiply(a: i32, b: i32) -> i32 { a * b}// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b }// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b:i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b:i32) -> i32 { a * b }
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a:i32,b:i32)-> i32{ return a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a:i32,b:i32)-> i32 { return a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a:i32,b:i32) -> i32{ a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a:i32,b:i32) -> i32{ a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a+b;}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a-b;}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a*b;}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a+b;}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a-b;}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a*b;}
pub fn add(a: i32, b: i32) -> i32 { a+b // Step 1: implement addition}// Step 2:pub fn subtract(a: i32, b: i32) -> i32{ a-b} // Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:pub fn multiply(a: i32, b: i32) -> i32{ a * b}// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract (a:i32, b:i32) -> i32 { a-b}pub fn multiply (a:i32, b:i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}pub fn subtract(a: i32, b: i32) -> i32 { a - b}pub fn multiply(a: i32, b: i32) -> i32 { a * b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}pub fn subtract(a: i32, b: i32) -> i32 { a - b}pub fn multiply(a: i32, b: i32) -> i32 { a * b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a:i32, b:i32) -> i32{ a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a:i32, b:i32)-> i32{ a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a:i32, b:i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32 , b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(lhs: i32, rhs: i32) -> i32 { lhs - rhs}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(lhs: i32, rhs: i32) -> i32 { lhs * rhs}
pub fn add(a: i32, b: i32) -> i32 { a + b}pub fn subtract(a: i32, b: i32) -> i32 { a - b}pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { // Step 1: implement addition a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { // Step 1: implement addition a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}pub fn subtract(a: i32, b: i32) -> i32 { a-b}pub fn multiply(a: i32, b: i32) -> i32 { a*b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { return a + b;}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a - b;}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a * b;}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32{ a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32{ a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract (a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply (a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { // Step 1: implement addition a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { // Step 1: implement addition a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b} // Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { a+b}pub fn subtract(a: i32, b:i32) -> i32 { a-b}pub fn multiply(a: i32, b:i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}pub fn subtract(a: i32, b: i32) -> i32 { // Step 1: implement addition a - b}pub fn multiply(a: i32, b: i32) -> i32 { // Step 1: implement addition a * b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a-b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a*b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}pub fn subtract(a: i32, b: i32) -> i32 { a - b}pub fn multiply(a: i32, b: i32) -> i32 { a * b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { a + b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { a * b}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a + b}// Step 2:pub fn subtract(a: i32, b: i32) -> i32 { a - b}// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:pub fn multiply(a: i32, b: i32) -> i32 { a * b}// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition return a + b;}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn subtract(a: i32, b: i32) -> i32 { return a - b;}// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.pub fn multiply(a: i32, b: i32) -> i32 { return a * b;}
pub fn add(a: i32, b: i32) -> i32 { // Step 1: implement addition a+b}pub fn subtract(a:i32,b:i32)->i32{ a-b}pub fn multiply(a:i32,b:i32)->i32{ a*b}// Step 2:// Define a public function named `subtract`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.// Step 3:// Define a public function named `multiply`// that accepts two arguments of type `i32`// and returns an `i32`.// make sure you make the function public by using the `pub` keyword.