In the following program, a nested loop is used to check how often the loops are run through.
a, b, c1, c2 = 5, 7, 0, 0
for i in range(20, a, -1):
c1 = c1 + 1
for j in range(0, b):
c2 = c2 + 1
if i == j:
print("How many times the loops are run?")
print(
"first loop: "
+ str(c1)
+ "\nsecond loop: "
+ str(c2)
+ " ("
+ str(c1)
+ " * "
+ str(b)
+ ")"
)
How many times the loops are run?
first loop: 15
second loop: 105 (15 * 7)