Question: Write a function in C named find_elem which takes the following arguments: integer elem integer array int size with size being the array size, and
Write a function in C named find_elem which takes the following arguments:
integer elem
integer array
int size
with size being the array size, and elem the element you have to find in the array.
If elem is part of the array, return the first position of the element in the array. If elem is not part of the array return -1
For example:
| Test | Output |
|---|---|
| int array[] = {4, 2, -6, -1}; printf("%d", find_elem(4, array, 4)); | 0 |
| int array[] = {4, 2, -6, -1}; printf("%d", find_elem(-4, array, 4)); | -1 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
