In any programming language, the mechanism for executing loop instructions (for and while) is similar, where in the for loop the number of iterations is done automatically until the end of the iteration is reached, while in the while loop we must increment the counter until we reach the end of the iteration.