To display Factors of given number using while loop

 Program:


#include<conio.h>
#include<stdio.h>
void main()
{
    int n, i=1;
    clrscr();
    printf("Enter any Number : ");
    scanf("%d", &n);
    printf("\n\nFactors of given Number is : \n\n");
    while(i<=n)
    {
        if(n%i==0)
            printf("\t%d", i);
            i++;
    }
    getch();
}

Output:


Enter any Number is : 10
Factors of Given Number us :
1    2    5    10


Next Topic        :  

Previous Topic :

No comments:

Post a Comment