Question
Write the function removeOdds() that removes all of the removes all of the odd numbers in its array parameter. We are currently working on Arrays
Write the function removeOdds() that removes all of the removes all of the odd numbers in its array parameter.
We are currently working on Arrays and Algorithms and I would appreciate some help with the function and below the picture is the support file.
/**
CS 150 PARTIALLY FILLED ARRAYS
Follow the instructions on your handout to complete the
requested function. You may not use any library functions
or include any headers, except for for size_t.
*/
#include // size_t for sizes and indexes
///////////////// WRITE YOUR FUNCTION BELOW THIS LINE ///////////////////////
///////////////// WRITE YOUR FUNCTION ABOVE THIS LINE ///////////////////////
// These are OK after the function
#include
#include
using namespace std;
void print(const int a[], size_t size);
void studentTests()
{
cout
cout
int a[100] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
size_t size = 12;
cout
cout
int numRemoved = removeOdds(a, size);
cout
cout "
cout 6"
cout
size = 0;
cout
numRemoved = removeOdds(a, size);
cout
cout "
cout -1"
int b[100] = {1, 2, 3, 3, 5, 12};
size = 6;
cout
cout
numRemoved = removeOdds(b, size);
cout
cout "
cout 4"
cout
cout
}
void print(const int a[], size_t size)
{
cout
if (size > 0)
{
cout
for (size_t i = 1; i
cout
}
cout
}
int main()
{
studentTests();
}
1 THE removeOdds PROBLEM Write the function removeOdds () that removes all of the removes all of the odd numbers in its array parameter. The function returns the number of items removed, or -1 if the array is initially empty. The function takes 2 arguments: the array of int that will be modified * the size of the array (use size_t as the type) Both of these will be input-output parameters int numRemoved removeodds (a, size); Input-output parametersStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started