Programming often requires performing the same task multiple times. Writing the same code repeatedly is inefficient and difficult to maintain. This is where loops come into the picture.

Loops allow us to execute a block of code repeatedly until a specified condition becomes false.

Why Do We Need Loops?

Suppose we want to print 1 five times.

Without loops, we would need to write: