Predict the output of the following code fragments:
c=0forxinrange(10):
foryinrange(5):
c+=1print (c)
Answer
Output
50
Explanation
Outer loop executes 10 times. For each iteration of outer loop, inner loop executes 5 times. Thus, the statement c += 1 is executed 10 * 5 = 50 times. c is incremented by 1 in each execution so final value of c becomes 50.