To display Natural Numbers from 1 to given number using for loop

 Program:


#include<stdio.h>
#include<conio.h>
void main()
{
    int n, i;
    clrscr();
    printf("Enter any Number : ");
    scanf("%d", &n);
    printf("\nNatural Numbers from 1 to %d is : \n", n);
    for(i=1; i<=n; i++)
    {
        printf("\t%d", i);
    }
    getch();
}

Output:

Enter any Number : 10
Natural Numbers from 1 to 10 is :
1    2    3    4    5    6    7    8    9    10


Next Topic        :  

Previous Topic :

No comments:

Post a Comment