diff --git a/control_flow/Cargo.lock b/control_flow/Cargo.lock new file mode 100644 index 0000000..b3e3f72 --- /dev/null +++ b/control_flow/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "control_flow" +version = "0.1.0" diff --git a/control_flow/Cargo.toml b/control_flow/Cargo.toml new file mode 100644 index 0000000..537ea1a --- /dev/null +++ b/control_flow/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "control_flow" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/control_flow/src/main.rs b/control_flow/src/main.rs new file mode 100644 index 0000000..b7681ca --- /dev/null +++ b/control_flow/src/main.rs @@ -0,0 +1,23 @@ +fn main() { + + //if else statements + let mut num1 = 10; + let mut num2 = 5; + + if num1 < num2 { + println!("{} is smaller then {}",num1, num2); + } + else + { + println!("{} is bigger then {}",num1,num2); + } + + //if expressions + //always need a else case and must be of the same type, ternary operations do not exist but this results the same + num1 = if num1 != num2 {5} else {15}; + println!("num 1: {}",num1) + + + + +}