Question: Write the following function: bool search(int a[], int n, int key, int *count); that is passed an integer array a of size n and a

 Write the following function: bool search(int a[], int n, int key,

Write the following function: bool search(int a[], int n, int key, int *count); that is passed an integer array a of size n and a value key to search for in a, and returns true if the value is found, false otherwise, plus the number of times the key is found back through the pointer count. You may not use any array subscripting in the function search! Here is a driver program you may use, if you choose, to test your function. It produces a warning message (from the printf in main) when compiled that you can safely ignore. #include #include #define N 10 bool search (int a[], int n, int key, int *count); int main(void) {int i, key, count; int list [N] = {2, 4, 6, 8, 2, 2, 0, 31, -6, 0}; printf ("Enter key to search for: "); scanf ("% d", & key); printf (search(list, N, key, & count)? "key is found % d time(s) ": "key is not found ", count); return 0;} bool search(int a[], int n, int key, int *count) {//your code goes here}

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