Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

Does it have a clear, engaging lead?

Answered: 1 week ago

Question

5. Who should facilitate the focus group?

Answered: 1 week ago