Question: Write a C++ function int find(int x[ ], int N, int target); that accepts an integer array x of size N, and returns the

Write a C++ function int find(int x[ ], int N, int target); 

Write a C++ function int find(int x[ ], int N, int target); that accepts an integer array x of size N, and returns the index of element target if it exists in the array. If it doesn't exist, the function should return -1. Test the above function by writing an appropriate main() program. All printouts should be done in main Sample run 1: Enter 5 elements: 2 4 6 8 10 Enter an element to search for: 6 The element is at index 2 Sample run 2: Enter 5 elements: 2 4 6 8 10 Enter an element to search for: 3 The element is not in the array

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the C function find that searches for an element in an integer array and returns its index if ... View full answer

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