What if you could tell the computer to do a task many times with just a few words?
Why For loop in C? - Purpose & Use Cases
Imagine you want to print numbers from 1 to 10 one by one. Doing this manually means writing ten separate print statements, like printf("1\n"); printf("2\n"); and so on.
This manual way is slow and boring. If you want to print 100 numbers, writing 100 lines is tiring and easy to make mistakes. Changing the range means rewriting many lines.
The for loop lets you repeat actions easily. You write the instructions once, and the loop runs them many times, changing the number automatically each time.
printf("1\n"); printf("2\n"); printf("3\n");
for(int i = 1; i <= 3; i++) { printf("%d\n", i); }
With a for loop, you can repeat tasks quickly and correctly, no matter how many times you need.
Think about counting items in a store or printing a list of names. A for loop helps you do this without writing repetitive code.
Writing repetitive tasks manually is slow and error-prone.
For loops automate repetition with simple, clear code.
They make programs easier to write, read, and change.