C Program to print natural numbers in range
#include<stdio.h>
int main()
{
int i, start, end;
printf("Enter Start Value: ");
scanf("%d",&start);
printf("Enter End Value: ");
scanf("%d",&end);
printf("Natural numbers from %d to %d : \n", start, end);
/* Start loop counter from start (i=start) and go till end (i<=end),
increment the loop count by 1 to get the next value */
for(i=start;i<=end;i++)
{
printf("%d\n",i);
}
return 0;
}
Output
Enter Start Value: 11
Enter End Value: 23
Natural numbers from 11 to 23 :
11
12
13
14
15
16
17
18
19
20
21
22
23