To print natural numbers in C


Levels of difficulty: / perform operation:

C a program to print natural numbers up to a given number.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	int i=1,n;
	clrscr();
	printf("\nENTER A NUMBER: ");
	scanf("%d",&n);
	printf("\nNATURAL NUMBERS UPTO %d ARE:\n",n);
	while(i<=n)
        {
		printf("%d ",i);
		i=i+1;
	}
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview