Q, 4 , 5 ,6

Hi Guys,

Kindly help me on below :

4. An array contains the elements shown below. Using the binary search algorithm,trace the steps followed to find 88. At each loop iteration, including the last, show the contents of first, last and mid.

(8,13,17,26,44,56,88,97)

5.Write a function that reverses the elements of an array so that the last element becomes the first, the second from the last becomes the second, and so forth.The function is to reverse the elements in place – that is, without using another array. Then write a test driver to test your function. Test it twice, once with an even number of elements in the array and once with an odd number of elements in the array.

6. Write a function that calculates the average number of characters per line in a file.

for num 6: the function i wrote as :

6 = total / 2
Average = 3
is that correct ?
Last edited on
for num 6: the function i wrote as :

6 = total / 2
Average = 3
is that correct ?


For the whole function? NO!

Hint:
-Accept a file to analyze
-Get the number of characters in file
-Get the number of lines in the file
-Average=num of chars/num of lines

Aceix.
Topic archived. No new replies allowed.