Week 8: Tuesday --------------- Q1. (30) Write a function that converts a decimal integer to the equivalent binary representation. Recall that a number in binary representation uses only two digits, 0 and 1. So, if a number is in this form an ... a1 a0 where a1 to an are binary digits (i.e., 0 and 1), it is equivalent to the integer a0 * 2^0 + a1 * 2^1 + ... + an * 2^n Your function should have the following prototype: void dectobin(int dec, int bin[], int *count) where dec is the input number in decimal. When the function returns bin should hold the sequence of bits (i.e., binary digits 0 and 1) representing the equivalent binary number and *count should hold the number of bits in bin. In the main() function, call dectobin on an integer input by the user and print the binary number using the contents of bin and *count. (You can get the binary representation of a number using repeated division by 2. You can use your own method as well.) Make sure to print the binary number in the correct order. So, if the decimal number is 6, you should print 110. Q2. (70) Here is a description of an algorithm called the insertion sort that, given an array of n numbers, sorts them in ascending order. 1. In the first iteration, assume that the number in the first position is sorted. Insert the second smallest number at the correct position. 2. In the (k-1)th iteration, the first k-1 elements will be sorted. Insert the kth element in the correct position to get k sorted elements from the beginning. 3. Repeat for n-1 iterations. For example, suppose n = 5 and the input array is: 2 4 1 5 3 In the explanation below, | indicates that the subarray upto | is sorted and the element followed by | needs to be inserted in the sorted subarray appropriately. Initially: 2 | 4 1 5 3 When k = 1: (insert 4 in to the sorted subarray) 2 4 | 1 5 3 When k = 2: (insert 1 in to the sorted subarray) 1 2 4 | 5 3 When k = 3: (insert 5 in to the sorted subarray) 1 2 4 5 | 3 When k = 4: (insert 3 in to the sorted subarray) 1 2 3 4 5 | Done. Write a program that implements insertion sort. The function should print the array contents before each iteration. In the main function, declare an array of size 8; ask the user to enter 8 integers into the array. Apply the sort function on this array.