Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ints The name of the file must be manipulator.cpp Write a program that manipulates an array of ints. The program should prompt the user for

image text in transcribed

ints The name of the file must be manipulator.cpp Write a program that manipulates an array of ints. The program should prompt the user for the size of the array, dynamically allocate it and then allow the user to enter the values. Your program should then define the functions described below, call them in order, and display - the results of each operation: a) reverse(): This function accepts a pointer to an int array and the size of the array. The function creates a copy of the received array, except that the elements should be in reverse order. The function should then return a pointer to the new array. b) expand: This function accepts a pointer to an array (the original array), a pointer to the reversed array, and the size of the array as its parameters. The function should create a new array that is twice the size of the argument arrays. The function should copy the contents of the original array to the new array in the first half and the reversed array in the second half. The function should then return a pointer to the new array c) shift): This function accepts a pointer to an array and the size of the array. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0The rest of the elements will be shifted to the right; element 0 of the argument array ill be element 1 in the new array, element 1 of the argument array will be element 2 in the new array, and so forth. The function should return a pointer to the new array d) mode): This function accepts a pointer to an array and its size as parameters and finds the mode in that array. The mode is the element that occurs most often. If the array has no mode, the function should return -1 Enter the size of the array: 8 Enter a size > 8: -2 Enter a size > 8: 6 Enter array values: 4 5 10 2 8 2 Values in reverse order: 2 8 2 10 54 Values in expanded array: 4 5 10 2 8 22 8 2 10 54 Values shifted to the right: 0 4 5 10 2 8 2 The mode is: 2

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions