Page 1 of 1

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

Posted: Fri Apr 29, 2022 6:45 am
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 23 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