Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement 3 functions in c++. Reverse Array, Remove Odd Numbers, and Split Parity I've gotten a reverseArray function to work: void reverseArray(int arr1[], int arr1Size){

Implement 3 functions in c++. Reverse Array, Remove Odd Numbers, and Split Parity

I've gotten a reverseArray function to work:

void reverseArray(int arr1[], int arr1Size){

int temp = 0;

for (int i = 0; i

temp = arr1[arr1Size-i-1];

arr1[arr1Size-i-1] = arr1[i];

arr1[i] = temp;

}

for (int i = 0; i

cout

}

cout

}

But am having trouble with the other two:

image text in transcribedimage text in transcribedimage text in transcribed

uestion 3: Implement following functions: a. void reverseArray (int arr[, int arrSize) That takes arr, an array of integers, and its size, arrSize. When called, it reorders the elements of the array to appear in a reverse order. For example, if arr is an array containing [1, 2, 3, 4], after calling reverseArray, arr will look like: [4, 3, 2,1]. b. void removeOdd (int arr[], int& arrSize) That takes arr, an array of integers, and its size, arrSize. When called, the function alters arr so that the only numbers in it at the end are the even ones, which should remain in their original relative order. Additionally, the function updates arrSizeso it contains the new logical size of the array after removing the odd numbers (note that arrSizeis a parameter used both for input and output). For example, if arr is an array containing [1, 2, 3, 4], after calling removeOdd, arr will look like: [2, 4], and the parameter arrSize will update to 2. Notice the values in arr [2] and arr [3] are discarded c. void splitParity (int arr[], int arrSize) That takes arr, an array of integers, and its size, arrSize. When called, the function changes the order of numbers in arr so that all the odd numbers will appear first, and all the even numbers will appear last. Note that the inner order of the odd numbers and the inner order of the even numbers don't matter. For example, if arr is an array containing [1, 2, 3, 4], after calling splitParity, arr could look like: [3, 1, 2, 4]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions