Open Code Block IDE, create a new project. Use this project to: o 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) o 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. o 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 o Create a program that o Defines a symbolic constant named SIZE of value 10 o Using the symbolic constant SIZE, creates a 1-D array named values of integer numbers to store 10 elements. o Uses the rand array function to fill the array with random values o Uses the print_array function to print the array o Prompts the user to enter an integer value in the range O to 10, store the value in a variable named n o Uses the print_smallest_k function to print the smallest n values in the array o 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 O and 10: 3 The smallest 3 values in the array are: -7-4-2

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C language

 

Open Code Block IDE, create a new project. Use this project to:
o 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)
o 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.
o 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
o Create a program that
o Defines a symbolic constant named SIZE of value 10
o Using the symbolic constant SIZE, creates a 1-D array named values of integer numbers to store 10 elements.
o Uses the rand_array function to fill the array with random values
o Uses the print_array function to print the array
o Prompts the user to enter an integer value in the range 0 to 10, store the value in a variable named n
o Uses the print_smallest_k function to print the smallest n values in the array
o 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-4 5-7
Input an integer between 0 and 10:3
The smallest 3 values in the array are: -7 -4-2
Transcribed Image Text:Open Code Block IDE, create a new project. Use this project to: o 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) o 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. o 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 o Create a program that o Defines a symbolic constant named SIZE of value 10 o Using the symbolic constant SIZE, creates a 1-D array named values of integer numbers to store 10 elements. o Uses the rand_array function to fill the array with random values o Uses the print_array function to print the array o Prompts the user to enter an integer value in the range 0 to 10, store the value in a variable named n o Uses the print_smallest_k function to print the smallest n values in the array o 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-4 5-7 Input an integer between 0 and 10:3 The smallest 3 values in the array are: -7 -4-2
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY