Question: Write a function in C++ called remove that removes elements from an array of ints if the number is evenly divided by the number provided(you
Write a function in C++ called remove that removes elements from an array of ints if the number is evenly divided by the number provided(you can find out if the number is evenly divided if you divided the array element by the % operator and it returns nothing(0))
The function remove takes 3 parameters:
-The int array a
-The size of the array (use size_t)
-The number provided ( use int)
The function remove returns the number of elements removed and -1 if it fails ( when there is no elements to remove/ the array is empty)
For example: int a[50] = { 5, 20, 15, 12, 16, 4,3 }
size_t = 7;
Calling the function int answer = removed(a, size, 3)
Will remove 15,12,3 and modify the array to {5,20,16,4} where size= 4 and removed = 3.
**You may not use any library functions or include any headers, except for for size_t and to print the function.
Please explain your steps. Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
