Problem: Program to print natural numbers from 1 to N.
Given a number, n, you need to print from 1 to n. The below program uses for loop to print 1 to n numbers.
#include<stdio.h>
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
printf("%d\n",i);
}
return 0;
}
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
printf("%d\n",i);
}
return 0;
}