C For Loop Examples
1. Print Numbers from 1 to 10
Output:
2. Print Even Numbers from 2 to 20
Output:
3. Sum of First N Numbers
Sample Input/Output:
4. Factorial of a Number
Sample Input/Output:
5. Multiplication Table
Sample Input/Output:
6. Nested for Loop Example – Pattern
Print a right-angle triangle:
Output:
7. Key Points
-
forloops are ideal when the number of iterations is known. -
Initialization, condition, and increment/decrement are in one line.
-
Can be nested for patterns, tables, or multi-dimensional tasks.
-
Loop variable can be declared inside or outside the loop.
