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

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

#include<stdio.h>

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