From f86921f3bdeecc4f5442c24aa6e92f9449926608 Mon Sep 17 00:00:00 2001 From: Livinalt Date: Wed, 2 Oct 2024 09:02:30 +0100 Subject: [PATCH] Cfeat:: Functions cmpleted :fArithmetic Operations Functions --- assignments/assignment_2.md | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/assignments/assignment_2.md b/assignments/assignment_2.md index e69de29..547844e 100644 --- a/assignments/assignment_2.md +++ b/assignments/assignment_2.md @@ -0,0 +1,44 @@ +fn main() { + + add(); + subtraction(); + multiply(); + division(); + +} + + +pub fn add() -> u8 { + let x: u8 = 24; + let y: u8 = 40; + let z: u8 = x + y; + println!("The value of Z is: {}", z); + z +} + + +pub fn subtraction() -> u128 { + let x: u128 = 404; + let y: u128 = 40; + let z: u128 = x - y; + println!("The value of Z is: {}", z); + z +} + + +pub fn multiply() -> u128 { + let x: u128 = 50; + let y: u128 = 40; + let z: u128 = x * y; + println!("The value of Z is: {}", z); + z +} + + +pub fn division() -> u8 { + let x: u8 = 400; + let y: u8 = 40; + let z: u8 = x / y; + println!("The value of Z is: {}", z); + z +}