Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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, 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started