Question: Please answer the questions correctly and show clear workings . Show the appropriate code and then the result that it works on your screen. 2.

Please answer the questions correctly and show clear workings . Show the appropriate code and then the result that it works on your screen.
 Please answer the questions correctly and show clear workings . Show

2. Write a second program called functions.c that contain the following functions. Ensure that your main function fully tests your functions with a variety of inputs. Write a function collatz(int n) using a do-while loop which should work as follows: a. i output the current value of n ii. if the n is even, halve it ii if the n is odd triple it and add 1 iv, repeat steps 1-3 until n = 1. HINT: You will need to use the modulo operator (%). Use a while loop to write a function divisors(int n) which prints out all divisors of n. Use continue to avoid printing the non-divisors of n b. Using a nested for loop, write a function non_primes(int n) which prints out all non-prime numbers smaller than n. Use break to avoid unnecessary computations. c

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!