Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ function named arrange that accepts an integer array, and its capacity, and returns an integer pointer that stores the address of a

Write a C++ function named arrange that accepts an integer array, and its capacity, and returns an integer pointer that stores the address of a new array which contains the same array elements in the following order: all odd numbers in reverse order, and all even numbers in reverse order. Therefore, you should create a new array in the function having the same size as the array in the parameter and copy all elements in the requested order. For instance, running the following code in the main function should print "13 7 3 4 6 12" and "15 9 11 19 4 22 6".

int a[] = { 3,7,13,12,6,4 };

int * b = arrange(a, 6);

for (int i = 0; i < 6; i++) {

cout << *(b+i) << " "; }

cout << endl;

int c[] = { 19,6,22,11,4,9,15 };

int * d = arrange(c, 7);

for (int j = 0; j < 7; j++) {

cout << *(d+j) << " "; }

cout << endl;

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

Students also viewed these Databases questions

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago