WAP to print natural numbers till the number given by the user

Write a program to print natural numbers till the number given by the user using while loop

#include<stdio.h>

int main() {
	int i=1,n;
	printf("Enter any number: ");
	scanf("%d",&n);
	while(i<=n) {
		printf("%d\n",i);
		i++;
	}
	return 0;
}

Output

Enter any number: 6
1
2
3
4
5
6

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments