Friday, 21 February 2014

Write a C program to print the factors of a number given by the user.

#include<stdio.h>
main()
{   
    int n,i=1;
    printf("\nEnter the number=");
    scanf("%d",&n);
    printf("\nThe factors are=");
    while(i<=n)
    {
        if(n%i==0)
            printf("%d ",i);       
        i++;
    }
}

No comments:

Post a Comment