+ 3
What are the loops
loops
4 Answers
+ 8
something that happens more than once
while ( alive == true)
{
breathe();
}
+ 6
Rust:
let dead: bool = false;
loop {
breathe();
if dead == true {
break; //And, you died. What an unfortunate story.
}
}
+ 3
loops are used to iterate / repeat statements number of times, for example if we have to print "hello world" 100 times, we can write the statement 100 times but it will be hard, so we can use loops to repeat the single statement 100 times and it will be easy and fast for us.
+ 1
for i in range(5):
breathe()