Pybites Logo Rust Platform

Basic Arithmetic in Rust

Level: intro (score: 1)

In this exercise, you'll implement a function that performs basic arithmetic operations on two integers.

Your function will return a tuple containing: 
- The sum of the numbers.
- The difference (first minus second).
- The product.
- The quotient as an Option<i32> (if the divisor is zero, return None).

This exercise helps you practice Rust’s arithmetic operators and simple conditional logic.

In real-world scenarios, such operations underpin everything from calculating daily expenses to computing mission-critical values in your favorite sci-fi adventure!

Hint: In Rust, the Option type is used to represent a value that may or may not be present. When a value exists, it's wrapped in Some(value).

When there is no value (for example, if dividing by zero), we return None.

Happy coding!