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

#include<stdio.h>

int main() {
	int i,n;
	printf("Enter any number: ");
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		printf("%d\n",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