Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Using C. Write a program called rearrange.c. that allows rearranging of the array elements by slicing the array at a specified position and put

Program Using C.

Write a program called rearrange.c. that allows rearranging of the array elements by slicing the array at a specified position and put the second part of the array to the beginning of the array and then append the first part.

As part of the solution, write and call the function rearrange() with the following prototype. The rearrange function should rearrange the array a1 with slicing position s so that the elements before position s are moved to the end of the elements after position s.

void rearrange(int n, int *a1, int s, int *a2);

The rearrange() function should use pointer arithmetic not subscripting to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.

In the main function, ask the user to enter the length of the array, declare the array with the length, read in the values for the array and the slicing position and call the rearrange function. The main function should display the result.

A sample input/output:

Enter the length of the array: 6

Enter the elements of the array: 3 4 9 8 7 2

Enter the slicing position: 3

Output:

The output array is: 9 8 7 2 3 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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

What did they do? What did they say?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago