+ 2

What is a loop?

what do you mean by loop and what are its functions?

13th Jan 2017, 10:26 AM
Sourabh Sahil
Sourabh Sahil - avatar
5 Answers
+ 8
It's a loooooooop... You may go round and round and round until the condition you have declared to terminate will not come. looping statements are used to execute a part of program more than one time. Let's say you want to divide a number 1000 by 2, and let it continue till the answer (quotient) will be 0, you use loop. eg. x=1000; While(x!==0) { x=x/2; }
13th Jan 2017, 11:15 AM
Sachin Artani
Sachin Artani - avatar
+ 5
A loop is a repetition, in meaning that it end where it start... To not infinitly repeat the loop, we associate mostly a ternary conditional test to decide or not to quit the loop at each iteration ( turn ), whatever at begin or end ( but this introduce a difference, that in case of testing at end, the loop is executed at least once, else the loop may be not executed at all ^^ ).
13th Jan 2017, 1:53 PM
visph
visph - avatar
+ 4
a loop generally refers to a for or while statement which will execute a block of code a specified amount of times. for example: for (int i = 0; i < 10 ; i++) { console.writeline ("Hello"); } //outputs "Hello" 10 times. int i = 0; is the variable that will keep track of number of times the code has been executed. i <10; specifies to keep doing this code while i is equal to less than 10. and i++ is telling the loop to increment i by 1 each time. Hope this helps.
13th Jan 2017, 11:21 AM
steven
steven - avatar
0
A loop is a function which repeats (or re-runs) a statement until the condition for its termination is met. An example is when you write a code to flash 'PRESS ANY KEY TO CONTINUE' on the screen, The notification will continue flashing on the screen till any key (WHICH IS THE CONDITION FOR ITS TERMINATION) is pressed. There are the WHILE, DO WHILE and FOR loop in C. Please note: This answer was given as is, based on my own understanding and knowledge of the question given and is subject to change and/or correction.
3rd Feb 2017, 12:23 PM
Ibeawuchi Uzodimma
- 1
loop is simply execution of a statement or statements for more than one time
28th Jan 2017, 3:13 PM
ŃŠĐŒŃ”Ń”Ń ĐŃ§ĐŒÓĄŃ§
ŃŠĐŒŃ”Ń”Ń ĐŃ§ĐŒÓĄŃ§ - avatar