• Create a function named rand_array, that takes as argument an array of integers and its size. Th function should fill

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

• Create a function named rand_array, that takes as argument an array of integers and its size. Th function should fill

Post by answerhappygod »

Create A Function Named Rand Array That Takes As Argument An Array Of Integers And Its Size Th Function Should Fill 1
Create A Function Named Rand Array That Takes As Argument An Array Of Integers And Its Size Th Function Should Fill 1 (39.47 KiB) Viewed 22 times
• Create a function named rand_array, that takes as argument an array of integers and its size. Th function should fill the array with random values between 10 and 10 inclusive (as in Lab 05) • Create a function named print_array, that takes as argument an array of integers and its size. The function should print the array elements consecutively ( on a single line) separated by a space. • Create a function named print smallest_k, that takes as argument an array of integers, its size, and an integer k. The function should print the k smallest elements in the array • Create a program that • Defines a symbolic constant named SIZE of value 10 . Using the symbolic constant SIZE, creates a 1-D array named values of integer numbers to store 10 elements. • Uses the rand array function to fill the array with random values • Uses the print_array function to print the array • Prompts the user to enter an integer value in the range 0 to 10, store the value in a variable named n Uses the print_smallest k function to print the smallest n values in the array • Organize the output as in the sample run Hint: sort the array in descending order to simplify "print largets_k" Sample Output The array is: 9-284-103-45-7 Input an integer between 0 and 10: 3 The smallest 3 values in the array are:-7-4-2
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply