C program to print all natural numbers from 1 to n using While
#include<stdio.h>
int main()
{
int n, i=1; /* i=1 use for start with 1 to n */
/* Input limit from User */
printf("Enter any Number: ");
scanf("%d",&n);
/* Start loop counter from 1 (i=1) and go till n (i<=n)
increment the loop count by 1 to get the next value */
while(i <= n)
{
printf("%d\n",i);
i++;
}
return 0;
}
Output
Enter any Number: 11
1
2
3
4
5
6
7
8
9
10
11