C Program to Print First n Numbers using While loop

Write C Program to Print First n Numbers using While loop

//WAP to print first N numbers using while loop

#include <stdio.h>

int main()
{
	int n;

	printf("Enter the number :--> ");
	scanf("%d", &n);

	int i = 1;

	while(i <= n)
	{
		printf(" %d\n",i);
		i++;
	}

	return 0;
}

Output:

Enter the number :--> 10
 1
 2
 3
 4
 5
 6
 7
 8
 9
 10

≪ Previous | Next ≫