Thursday, September 20, 2012

program for natural numbers upto a limit

c program code for printing n natural numbers using while loop.....
First we need to input the value of n,that is the limit.Then the program automatically produce the natural numbers up to that limit.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=0;
clrscr();
printf("Enter the value\n");
scanf("%d",&n);
while(i<=n)
{
printf("%d\n",i);
i++;
}
getch();
}

No comments:

Post a Comment