add for loops
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user