diff --git a/control_flow/src/main.rs b/control_flow/src/main.rs index 51b3d44..d8c5a8e 100644 --- a/control_flow/src/main.rs +++ b/control_flow/src/main.rs @@ -61,5 +61,29 @@ fn main() { loop_cycles += 1 }; - println!("it took {} cycles to resolve the expression",result) + println!("it took {} cycles to resolve the expression",result); + + //while + loop_cycles = 1; + while 5 > loop_cycles { + if loop_cycles == 2 + { + loop_cycles +=1; + continue; + } + println!("while loop {}",loop_cycles); + loop_cycles += 1; + } + + //for loops + //1..5 is 1 up to 5 not including 5 + for x in 1..5 + { + println!("for loop: {}",x); + } + //1..=5 is 1 up to and including 5 + for x in 1..=5 + { + println!("for loop including: {}",x); + } }