How do loops improve programming efficiency? |
[Edit] |
Answer
Who ever said they add efficiency?
Loops have one definite positive and one VERY large negative...
First the positive:
loops are sometimes good because once compiled they are ran over again until they reach their limit or positive/negative condition. It isn't new code that needs to be reconsidered by the computer at each pass.
However, the really negative thing you run into with loops is failing to set an absolute end loop run. Computers do what they are told and without having a backup way for the loop to definitely stop - it could run infinitively until each call that is made eventually eats all the memory and the program overloads the system.
Basically - if you write a loop, be sure to set an end loop... even the best programmers make this small little mistake sometimes.
First answer by Amysolen. Last edit by Amysolen. Contributor trust: 25 [recommend contributor]. Question popularity: 10 [recommend question]
|
Research your answer: |



