1. Engineering
  2. Computer Science
  3. code must be in c implement a function that will...

Question: code must be in c implement a function that will...

Question details

Code must be in C

Implement a function that will search for a given integer in an array of integers. The function should provide the user (i.e., the calling program) with the number of occurrences of the integer and the index of the location of the first occurrence.

The first thing you'll need to consider is what parameters your function will need. It will clearly need the array, an integer giving the size of the array, and the integer to be found in the array. Next, how will the two pieces of information be passed back to the user? Hint: you’ll probably need at least one of the parameters to be passed by reference.

You’re the one creating this function for other people to use, so you’re free to name it whatever you want and decide what prototype/interface you think makes the most sense. Note that you'll need to implement the main program to test your function to make sure it works correctly.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution