Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Write a program that performs several operations on an array of positive ints. The program should prompt the user for the size of the

- Write a program that performs several operations on an array of positive ints. The program should prompt the user for the size of the array (validate the size) and dynamically allocate it. Allow the user to enter the values, do not accept negative values in the array. - 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 and stores the elements in reverse order. 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 two elements larger than the argument array. Store -1 in the first two elements of the new array. The rest of the elements will be shifted by two to the right; first element of the argument array will be third element in the new array, second element of the argument array will be fourth element in the new array, and so on. 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 the most. If the array has no mode, the function should return -1.

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_2

Step: 3

blur-text-image_3

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

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

Students also viewed these Databases questions

Question

What is Accounting?

Answered: 1 week ago

Question

Define organisation chart

Answered: 1 week ago

Question

What are the advantages of planning ?

Answered: 1 week ago

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

Employ effective vocal cues Employ effective visual cues

Answered: 1 week ago