+ 3

Anyone to explain in details what loops are for me?

Not understanding loops properly

17th Sep 2017, 8:35 PM
Leonard Ojojo
Leonard Ojojo - avatar
5 Antworten
+ 13
Loop is a concept in programming to repeat a piece of code inside it. There can be generally two types of loops - an iteration ("for") loop and a conditional ("while") loop. A typical "for" (for/foreach/etc.) loop will repeat the code block inside it a particular number of times (unless given a "break"), usually assigning something to its iterator variable. During each iteration, the value is changed to the consecutive element of the iterator. Whereas a typical "while" loop will repeat it as long as its condition is true. When the condition is always true, this will turn into infinite loop and has to be somehow exited (broken) inside the code block. In some languages this loop type has a variant - a do-while loop. The difference between a normal while is that the condition is checked not at the beginning, but at the end of the loop. This is why a do-while loop will always execute at least once.
17th Sep 2017, 9:04 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
There's two types of loops (while lopps and for loops) basically it tells ur programme to run untill a certain condition is fulfilled for example a=1 while (a <5) { a++; console.writeline (a); }
17th Sep 2017, 8:59 PM
jay
+ 2
and also this dude will go over loops check him out and leave him a comment about ur questions.
17th Sep 2017, 9:01 PM
jay
+ 1
loop means repeating something until a certain condition is reached it can be repeated a number of times or infinite, for example you have a text file that caontains 20 lines of text and you want to print all lines so you have to do this by creating a loop that repeats 20 times , an example for infinite loop is showing clock in your application , finally sorry for my bad english and hope you understand it.😤
17th Sep 2017, 9:00 PM
Brya Mk
Brya Mk - avatar
+ 1
Still not clear with
17th Sep 2017, 9:03 PM
Leonard Ojojo
Leonard Ojojo - avatar