Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

write C program

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 following functions Define and implement a function named printArray that receives two parameters: an array a of integers and its size n. The function should prints the contents of the array Define and implement a function named randomFillArray that receives two parameters: an array a of integers and its size n. The function should fill the array with n random integer values in the range -43 to 57 (inclusive) Define and implement a 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 a 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) If x = 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 c, the size of sizes for array and the size of the second array. The function erges the two sorted lists a and b into a new sorted list c. This can be done using size 1 + size2 comparisons where sizel and size2 are the sizes for first and second lists respectively Implement a main function that performs the following: o Defines three integer arrays al of size 10, a2 of size 20 and a3 of size 30. o Uses function randomFillArray defined above to randomly intlize the array a1. o Uses function printArray to print the array a1 after intlization Uses function randomFillArray defined above to randomly intlize the array a2. Uses function printArray to print the array a2 after intlization 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 shuffleArray o Uses function sortArray to sort the values in al. o Uses function sortArray to sort the values in a2. Uses function mergeTwoLists to merge the content of al and a2 and store the merged list in a Uses function printArray to print the array a3 after shuffling

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions