Oops! I had some typos in that last questions. The input/output examples were wrong In the C(89) standard of C programming language Suppose you are given an array of integers. You want to insert a number x to the array and rearrange so that all the elements are less than or equal to x are before x, and the elements after x are greater than x. For example, suppose the list is {3, 2, 7, 0 1, 5} and x is 4, since 3, 2, 0, and 1, are less than or equal to 4, 7and 5 are greater than 4, the new array is {3, 2, 0, 1, 4, 7, 5}. The new array has the length of n+1 where n is the length of the input array. Example input/output #1: Enter the length of the array: 10 Enter the elements of the array: 3 5 1 4 0 3 9 2 8 11 Enter the number for insertion: 3 Output: 3 1 0 3 2 3 5 4 9 8 11 Example input/output #2: Enter the length of the array: 8 Enter the elements of the array: 5 0 13 4 1 7 3 5 Enter the number for insertion: 6 Output: 5 0 4 1 3 5 6 13 7 1) Name your program arrays.c 2) Include the rearrange( ) function to rearrange the array: void rearrange(int *a, int n, int insert, int *b); a represents the input array with length n, and b represents the output array. insert represents the number for insertion. This 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. <== This is the really important part. 3) In the main function, ask the user to enter the length of the input array, declare the input array. Then ask the user to enter the elements of the array, and the number for insertion. Then call the rearrange function to rearrange and store the elements in array b, then display the output array. 4) Pointer arithmetic is NOT required in the main function.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Oops! I had some typos in that last questions.
The input/output examples were wrong

In the C(89) standard of C programming language

Suppose you are given an array of integers. You want to insert a number x to the array and rearrange so that all the elements are less than or equal to x are before x, and the elements after x are greater than x. For example, suppose the list is {3, 2, 7, 0 1, 5} and x is 4, since 3, 2, 0, and 1, are less than or equal to 4, 7and 5 are greater than 4, the new array is {3, 2, 0, 1, 4, 7, 5}. The new array has the length of n+1 where n is the length of the input array.

Example input/output #1:
Enter the length of the array: 10
Enter the elements of the array: 3 5 1 4 0 3 9 2 8 11
Enter the number for insertion: 3
Output: 3 1 0 3 2 3 5 4 9 8 11

Example input/output #2:
Enter the length of the array: 8
Enter the elements of the array: 5 0 13 4 1 7 3 5
Enter the number for insertion: 6
Output: 5 0 4 1 3 5 6 13 7

1) Name your program arrays.c
2) Include the rearrange( ) function to rearrange the array:

void rearrange(int *a, int n, int insert, int *b);

a represents the input array with length n, and b represents the output array. insert represents the number for insertion. This 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. <== This is the really important part.
3) In the main function, ask the user to enter the length of the input array, declare the input array. Then ask the user to enter the elements of the array, and the number for insertion. Then call the rearrange function to rearrange and store the elements in array b, then display the output array. 4) Pointer arithmetic is NOT required in the main function.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education