Question: In C language a) Write a function called print_divisors that takes as parameter an unsigned long number n and that displays all its divisors less

 In C language a) Write a function called print_divisors that takes

In C language

a) Write a function called print_divisors that takes as parameter an unsigned long number n and that displays all its divisors less than n. 1 is considered a divisor. A positive integer number b is a divisor of a positive integer number a if a % b ==0. For instance, the divisors of 12 are 1, 2, 3, 4, 6, and 12, The function should only print divisors less than n. For example, if one calls print _divisors(18) the function determines the divisors are 1, 2, 3, 6,9 and prints them in this order. Hint: an easy way to find all divisors of n is to write a loop and try as divisors all numbers between 2 and n/2. Write the function interface comment, with proper precondition and postcondition. b) Write a function called add_divisors that tak es as parameter an unsigned long number n and that returns the sum of all of n's divisors less than n. For instance, the call add_divisors (18) should return 12 +3+6+9-21 Write the function interface comment, with proper precondition and postcondition. c) Write a main function that repeatedly reads a positive number m from the user and then finds (and prints to the terminal) all numbers between 2 and m for which the sum of m's divisors (including 1, but excluding m) is equal to m itself. The program ends when the user enters 0. Test your program thoroughly so that all conditional branches are checked. Include a screenshot in the PDF file with the program output in the terminal

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!