Question
Print Numbers from 1 to 10 using while loop in C Language
Solution
✔ Verified
This C program demonstrates how to use a while loop to print numbers from 1 to 10.
The while loop is an entry-controlled loop, meaning the condition is checked before the loop body is executed. The program initializes a counter variable and increments it in each iteration until it reaches 10, printing the value during each loop cycle.
#include <stdio.h>
int main() {
int i = 1;
while(i <= 10) {
printf("%d\n", i);
i++;
}
return 0;
}
Output:-
1
2
3
4
5
6
7
8
9
10
Click here to download practice questions on
While loop in C