To display Natural numbers from 1 to given number is using do-while loop

 Program:


#include<stdio.h>
#include<conio.h>
void main()
{
    int n, i=1;
    clrscr();
    printf("Enter any Number : ");
    scanf("%d", &n);
    printf("\n Natural Numbers from 1 to %d  is : \n", n);
    do
    {
        printf("\t%d", i);
        i++;
    }while(i<=n);
    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