+ 3

Please tell me what is a "LOOP"???

I have sololearn lesson but I can't understand that point only otherwise sololearn is BEST PLZ HELP ME,I AM BEGGINER 14 YRS

21st Oct 2017, 3:58 PM
Anmol Batra
Anmol Batra - avatar
5 Réponses
+ 17
Again and again and again and again.... and again and again...and..*stop* Doing a particular task repetitively everytime a particular condition is True The task gets terminated when the condition gets False eg: For Loop for(int x=0; x<5; x++) cout<<x; //Output 01234 In the above loop x=0 is less than 5 so it gets printed and then x++ causes increment (+1) so now x is 1 which is also less than 5 and gets printed. Moving on to 4 it will increment to 5 which isn't less than 5 so the loop gets terminated. So the loop was of printing the value of x until a particular condition (<5) was satisfied and once it becomes False the loop ends.. Same goes for while , do while loops
21st Oct 2017, 4:06 PM
Frost
Frost - avatar
+ 4
it is used to do a particular task again and again. it's your wish how many times you want that particular task to be repeated, accordingly you write the code. there are for loop, while loop, do while loop. based on your requirement and logic use the appropriate loop and write your code. all the best.
22nd Oct 2017, 2:35 AM
Talluri Saisumanth
Talluri Saisumanth - avatar
+ 2
Lets say you want to read data from a file. The data is separated on multiple lines and for each line you want to execute a series of commands. What do you do? You write a while LOOP where the condition is that you still have lines to read. Basically when you need to execute a command or more command multiple times you use a loop, a while loop when you don't know how many times it should run or a for loop otherwise.
21st Oct 2017, 4:44 PM
bogdan
bogdan - avatar
+ 2
Doing repetitive task Like doing pushups 20x. You'll do pushup repetitively until you do it 20x and then you finally stop
22nd Oct 2017, 12:39 AM
Theofratus
Theofratus - avatar
+ 2
Same tasks repeated until an exit condition is met. There are different types of loops. Practice on simple for loops. :)
27th Oct 2017, 4:43 AM
Marco G.
Marco G. - avatar