This challenge is about basic mathematical operations. You will be given 2 numbers a
and b
. You need to perform the following operations:
a
and b
a
and b
a
and b
a
and b
You need to return a tuple containing the results of the above operations in the same order. (sum, difference, multiply, divide)
Note that every value in the tuple must be of type
i32
.
let a = 10;
let b = 5;
let result = math_operations(a, b);
assert_eq!(result, (15, 5, 50, 2));
In Rust you can use the following operators for the above operations:
+
-
*
/
Good luck!
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) ( a + b, a - b, a * b, a / b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a +b ; let dif = a - b ; let mul = a * b ; return (sum , dif,mul,a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a + b; let diff = a - b; let mul = a * b; let div = a / b; return (sum, diff, mul, div);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) return (a + b, a - b, a * b, a / b);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum: i32 = a + b; let diff: i32 = a - b; let mult: i32 = a * b; let div: i32 = a / b; (sum, diff, mult, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum: i32 = a + b; let difference: i32 = a - b; let product: i32 = a * b; let quotient: i32 = a / b; (sum, difference, product, quotient)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum: i32 = a + b; let difference: i32 = a - b; let multiply: i32 = a * b; let divide: i32 = a / b; (sum, difference, multiply, divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) return (a+b, a-b, a*b, a/b);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) return (a+b, a-b, a*b, a/b);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a + b; let difference = a - b; let multiply = a * b; let divide = a / b; (sum, difference, multiply, divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let div: i32 = a / b; (a + b, a - b, a * b, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum = a + b; let diff = a - b; let mul = a * b; let div = a / b; (sum, diff, mul, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum = a + b; let diff = a - b; let mul = a * b; let div = a / b; (sum, diff, mul, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum: i32 = a + b; let diff: i32 = a - b; let mul: i32 = a * b; let div: i32 = a / b; (sum, diff, mul, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) return (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a + b, a - b, a * b, a / b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum = a + b; let diff = a - b; let mult = a * b; let div = a / b; (sum, diff, mult, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum = a + b; let diff = a - b; let mult = a * b; let div = a / b; (sum, diff, mult, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum: i32 = a + b; let difference: i32 = a - b; let multiply: i32 = a * b; let divide: i32 = a / b; return (sum, difference, multiply, divide);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a + b, a - b, a * b, a / b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a + b; let difference = a - b; let multiply = a * b; let divide = a / b; (sum, difference, multiply, divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) return (a+b,a-b,a*b,a/b);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a + b; let diff = a - b; let mult = a * b; let division = a / b; (sum, diff, mult, division)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let (sum, difference, multiply, divide): (i32, i32, i32, i32) = ((a + b), (a-b), (a*b), (a/b)); return (sum, difference, multiply, divide);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b as i32, a-b as i32, a*b as i32, a/b as i32)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let sum = a + b; let diff = a - b; let mult = a * b; let div = a / b; return (sum, diff, mult, div);}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let Sum : i32 = a + b; let Difference: i32 = a - b; let Multiplication: i32 = a * b; let Divide: i32 = a/b; (Sum, Difference, Multiplication, Divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b,a-b,a*b,a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { (a+b,a-b,a*b,a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide)(a+b,a-b,a*b,a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a + b, a - b, a * b, a / b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b, a-b, a*b, a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { let add = a + b; let sub = a - b; let mul = a * b; let div = a / b; (add, sub, mul, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) ((a+b),(a-b),(a*b),(a/b))}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a+b,a-b,a*b,a/b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) (a + b, a - b, a * b, a / b)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum = a + b; let sub = a - b; let mult = a * b; let div = a / b; (sum, sub, mult, div)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum: i32 = a + b; let difference: i32 = a - b; let multiply: i32 = a * b; let divide: i32 = a / b; return (sum, difference, multiply, divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum: i32 = a + b; let difference: i32 = a - b; let multiply: i32 = a * b; let divide: i32 = a / b; (sum, difference, multiply, divide)}
pub fn math_operations(a: i32, b: i32) -> (i32, i32, i32, i32) { // TODO: Return a tuple of 4 values: (sum, difference, multiply, divide) let sum: i32 = a + b; let difference: i32 = a - b; let multiply: i32 = a * b; let divide: i32 = a / b; (sum, difference, multiply, divide)}