## Consider the following algorithm for converting a decimal number into a binary number:

Question
• Obtain a decimal number from the user and store it in an integer variable named N.
• Perform an integer division to divide this number by 2 and store the result in N.
• Store the remainder in the next available position in an array.
• Repeat the above two steps while N is greater than zero.

The result is obtained by printing the array in reverse order.
a) Trace the steps in this algorithm to show what happens step-by-step when the initial decimal number is 10.
b) Provide code in a language of your choice that shows how this algorithm might be implemented as a function or procedure. Your answer should include the code necessary to invoke the function or procedure. This will prompt the user for a decimal value and output the answer as 8 binary digits. You can assume that the user will only enter values of N in the range 0 <= N <= 255.

c) With respect to this example, explain the difference between calling a function by value and by reference.

d) Explain the difference between functions and procedures.