. Use the instructions on the following pages to create

In this task you will create a simple program which will create an array with a user specified size. This array will then be populated with values, printed out to the console, and then, we’ll use the values to calculate some basic statistics. Use the instructions on the following pages to create a small program to explore the use of arrays. Submit the following files to Doubtfire. Your program code A screen shot of your program running The focus of this task is on the declaration and use of arrays. SIT102 Introduction to Programming Pass Task 6.1: Working with Arrays Overview Submission DetailsLets get started. 1. Watch the Working with Arrays video as a background for this task, you will need to implement the same logic but will read in double values rather than integers. 2. Create your own Working With Arrays project, and copy in the code of your user input functions, or your custom terminal user input code file and header. 3. Add the following functions and procedures based on the Working with Arrays video: Create a print_values procedure to print out a list of double values. void print_values(double values[], int size) { //… } Create a read_values procedure to read in a list of double values. void read_values(double values[], int size) { //… } Create a sum function to calculate the sum of an array of double values. int sum(double values[], int size) { //… } 4. Use the following as main for your program: int main() { int count; count = read_integer(“How many values: “); double temp[count]; read_values(temp, count); print_values(temp, count); write_line(“Sum is:”); write_line( sum(temp, count) ); return 0; } Instructions5. Extend the program with the following additions: Add a function that calculates and returns the count of the number of negative values (those < 0) in the array. int count_negative(const double data[], int size) { // … } For this you will need a local result variable that starts at 0, and you add one to the result for each element of the array that is < 0 . Print out the count of the number of negative values at the end of the program. Add a function that calculates and returns the largest value in the array. double maximum(const double data[], int size) { // … } For this you will need a local result variable that starts with the value of the first element of the array. You can then loop over the remaining array elements (from index 1 to the last).

Leave a Reply

Your email address will not be published.