Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise Exercise Objectives Applying random number generation Passing 1-D arrays to functions Call by reference Problem Description Write and run a C program with the

image text in transcribed
Exercise Exercise Objectives Applying random number generation Passing 1-D arrays to functions Call by reference Problem Description Write and run a C program with the flowing functions Define and implement a function named printrray that receives two parameters: an array o of integers and its size n. The function should print the contents of the array Define and implement a function named randomFillArray that receives two parameters: an array of integers and its size n. The function should fill the array with a random integer values in the range -43 to 57 (inclusive) Define and implementa function named sortArray that receives two parameters: an array a of Integers and its size n. The function should sort the array Define and implement a function named shuffleArray that takes two parameters: an array and its size n. The function should do the following: 1) Generate a random number that represents an index x in the array, and generate another random number that represents an index y in the array. 2) Swap the array element at index x with the array element at index y. 3) fx=y no swap should occur 4) The function should repeat steps 1, 2, and 3 n times. 5) The function should find and returns the number of swaps that have been done. Define and implement a function named mergeTwolists that takes five parameters: three floating point arrays a, b, and the size of sizes for array, and the size of the second array. The function merges the two sorted lists a and b into a new sorted list. This can be done using sizel + size2 comparisons where size and size are the sizes for first and second lists respectively Implement the main function that performs the following Defines three integer arrays al of size 10, a2 of size 20, and a3 of size 30. Uses function random FillArray defined above to randomly initialire the array al Uses function printArray to print the array al after initialization Uses function random FillArray defined above to randomly intialize the array o2. Uses function printArray to print the array a2 after initialization Uses function shuffleArray to shuffle the values in al Uses function printArray to print the array al after shuffling Print the number of swaps performed in the function shuttleArray Uses functions sortArray to sort the values in al Uses function sertray to sort the values ina2 Uses function mergeTwolists to merge the content of al and a2 and store the merged out in a Unes function priathnay to print the array asaher shuffline 00000000

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

MySQL/PHP Database Applications

Authors: Brad Bulger, Jay Greenspan, David Wall

2nd Edition

0764549634, 9780764549632

More Books

Students also viewed these Databases questions

Question

How do you add two harmonic motions having different frequencies?

Answered: 1 week ago

Question

demonstrate the importance of induction training.

Answered: 1 week ago