Question: Exercise 5 : Search in an array with pointers ( a ) Wrire the following function: int search ( int a [ ] , int

Exercise 5: Search in an array with pointers
(a) Wrire the following function:
int search(int a[], int n, int key)
a is an array to be searched, n is the number of elements in the array, and key is the key being searched. search
should return TRUE (1) if key matches some element of a, FALSE (0) if it doesn't. Use pointer arithmetic - not
subscripting - to visit array elements
(b) Assume that the following array contains a week's worth of hourly temperature readings, with each row containing
the readings for one day:
int temperatures[7][24];
Write a function that uses the search function, defined in (a), to search the entire temperatures array for a value,
val, and returns the row in which it is found.
(c) Write a function that uses a loop to print all temperature readings stored in row i of the temperatures array. Use a
pointer to visit each element of the row.
(d) Write a driver program to test all your functions.
Exercise 5 : Search in an array with pointers ( a

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 Accounting Questions!