C Program Print First N Natural Numbers

By | March 7, 2020

C Program Print First N Natural Numbers

Output:

Enter a number to show natural numbers from 1 to N:25
Numbers from 1 to 25 are:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

C Code for Displaying First N Natural Numbers Using For Loop

#include<stdio.h>
int main()
{
    int n,i;
    
	printf("Enter a number to show natural numbers from 1 to N:");
	scanf("%d", &n);
	printf("Numbers from 1 to %d are:\n",n);
	
	for(i=1;i<=n;i++)
	printf("%d\n", i);
    
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *