COP2220 Fall 2015Midterm Exam Practice 2

1-

Code a C function that accepts as parameters 3 arrays of integers and their respective sizes. The function should merge the contents of the two first arrays into the third. The third array is large enough to hold the contents of both the first and the second array. (you should assume that size of third array is equal to size of array one plus size of array two and that size of one and two are different).

2-

Code a C function (function one) that prompts the user to enter an integer. This same function (one) is assumed to have an array of n integers that is already populated by n integers. This function (one) should call another function (two) that accepts as parameters the array of integers, its size, and the integer entered by the user in function (one). Function (two) should check how many times the integer passed from function (one) occurs in the array at even positions (note: even position), and return that count.

3- (You must use pointers to arrays in this function for all processes: 10 points penalty if coded without pointers)

Code a C function that declare an array of 26 entries populated by the letters of the English alphabet (a,b,c,…,z). This array is hard coded and initialized with the letters of the alphabet in the correct order.

This function accepts as parameters a pointer to array of integers and its size. This function should traverse the array of integers, read each integer and display the corresponding letter from the array of alphabet. (Example: while traversing the array of integers, if integer 5 is read then this integer correspond to the letter ‘e’ of the alphabet. This letter ‘e’ is found at a position in the array of alphabet where letter ‘e’ is stored)(watch out: array starts at index zero!!!!!) (the design is up to you)

Extra

a-Code a C function that accepts two sorted arrays of integers and their respective sizes, merge them into another array large enough to hold both and end up with a merged and sorted array. You are required to sort while merging. You cannot merge both arrays into the third one then sort. (use pointers, if not partial credits would be given still)

b-Re-code the function in a, this time the function must return the merged and sorted array (use pointers ).

Page 1 of 1