Both for loop and while loop is used to execute the statements repeatedly while the program runs.