Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c Write a C program to do the following: 1. Define a function named merge that takes as arguments a. Two arrays of integers

in c
image text in transcribed
image text in transcribed
Write a C program to do the following: 1. Define a function named merge that takes as arguments a. Two arrays of integers b. The sizes of each array (not necessarily the same) c. A third array of integers named results The function should merge the contents of the first two arrays into the third array such that the third array will contain all the elements of the other two arrays sorted in descending order. 2. Define a function named add that receives an array of integers and its size. Also, this function must receive an integer variable representing the value to be added to array. The function must do the following: a. Search the array to make sure the value to be added does not already exist in the array. If the value does not exist it must be added in the first empty position in Pape 1 of 3 the array. If the value is found in the array the function prints "value already exists" to the screen. Note: a position is considered empty if its value is 1 b. If the array is full the function prints to the screen "Acray is Full" 3. Define a function named Remove that receives an array and its size alone with the value to be removed. The function must do the following: a. Search if the value to be removed exists in the array or not if the value is not found, print to the screen "value not found". b. If the value is found it must be removed by shifting all the elements in the array to the left by one position. c. Make sure that any empty positions has the value 1 4. In main function do the following: a. Define two arrays of type integer each of size 7 . b. Fill the arrays based on values entered from the uses. Enter 1 to indicste that this location is empty when the number of elements is smaller than the array size. c. Define a third array named result of type integer of size 20 . d. Merge the two arrays into the array result usine the function merge. e. Print the merzed array. 1. Read a value from the user and add it to the second array you defined E. Read a value from the user and remove it from the second array vou defined. h. Read a value from the user and add it to the second arrey you defined. 1. Print the second array you defined Sample Run Please enter the elements for array 1 367101211 Please enter the elements for array 2 2458912 Page 2 of 3 1 The merged array is 12,12,10,9,8,7,6,5,4,3,2,1,1,1,1,1,1,1,1,1 Enter a value to add to array 2 5 value already exists Enter a value to remove from array 2 4 Enter a value to add to array 2 6 2,5,8,9,12,6,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

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions

Question

A mental grouping of similar things is called a .

Answered: 1 week ago