At times, we want to repeat our code, so we use loop statements to
control the number of iterations. Determine the best way to stop a loop
from running infinitely and define the process used to verify that the loop is working correctly.
a loop has three basic components; the starting condition, ending condition and an iterative to update some variable to check the loop condition at next iteration of loop.
Infinite loops can occur due to failure of any of above three conditions, specially ending condition. if ending or termination condition of the loop is not implemented correctly, loop goes into infinite iterations.
Termination condition is to check when to terminate the loop.
Apart from these conditions, working of loop can also be checked by debugging.