Problem 57: Divisors

Write a function that takes an integer as input and prints all of its divisors. Call this function from the main function.

 

4,336 total views, 2 views today

Comments

comments

2 thoughts on “Problem 57: Divisors”

  1. #include

    int devisors(int number,int i)
    {
    printf(“Enter here a number:”);
    scanf(“%d”,&number);
    int devisors=number%i;
    for(i=1;i<=number;i++){
    if(number%i==0){
    printf("%d ",i);
    }
    }
    return devisors;
    }
    int main()
    {
    int number,i,result;
    result=devisors(number,i);

    return 0;
    }

  2. #include

    int divisor(int number);
    int main()
    {
    int number;
    printf(“Enter the number: “);
    scanf(“%d”,&number);
    divisor(number);
    getchar();

    }
    int divisor(int number)
    {
    int i;
    for (i=1;i<=number;i++)
    {
    if(number%i==0)
    printf("%d",i);
    }
    return 0;
    }

Leave a Reply

Your email address will not be published.