Question
Print Numbers from 1 to 10 using for loop in C Language.
Solution
✔ Verified
This C program demonstrates how to print numbers from 1 to 10 using a for loop.
The for loop is a control flow statement that allows code to be executed repeatedly based on a condition.
In this program, we initialize a counter variable to 1 and increment it by 1 in each iteration, continuing the loop as long as the counter is less than or equal to 10. During each iteration, the current value of the counter is printed to the console. This is a simple and effective way to understand the basic structure and usage of the for loop in the C programming language.
#include <stdio.h>
int main() {
for (int i = 1; i <= 10; i++) {
printf("%d\n", i);
}
return 0;
}
Output:--
1
2
3
...
10
Click here to download practice questions on
For Loop In C