0
I am learning all these loops by heart, but I have no idea what they are for?
I am learning all these loops, but I don't have any clue what they are for?
2 Answers
+ 2
They are for iteration(repitition) with a certain criteria.
Example If you want to print table of 2, instead of writing cout lines again and again ,this can be done in 2 lines with loops.
+ 2
the purpose of using a computer is to exploit its ability to do a lot of calculations really fast.
you can write your program typing 100 times the same calculation. (A program with 100 lines of code)
OR
writing ONE time the calculation and instructing how many times to operate your calculation (a program with only 3 lines of code): this is accomplished with loops.
Start coding to really understand and apprreciate how useful loops are.