your working with arrays program to use a dynamic

In this task you will change your working with arrays program to use a dynamic array (vector in C++) to keep track of a number of values for the user. 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 dynamic arrays (using the vector class in C++). SIT102 Introduction to Programming Pass Task 6.2: Working with Vectors Overview Submission DetailsLets get started. 1. Watch the Working with Vectors 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. Return to your own Working With Arrays project, and make the same changes as shown in the video: Include the vector library Make sure you have using namespace std; Change all of the array parameters to make use of vector Remember to use .size() to get the size of the vector. Use .push_back(…) to add data to the end of the vector. Remember to use pass-by-reference with all of the vector parameters: eg. void print_values(const vector &values) { … } . 3. Use the following as main for your program: int main() { int count; vector temp; count = read_integer(“How many values: “); read_values(temp, count); print_values(temp); write_line(“Sum is:”); write_line( sum(temp) ); write_line(“The number of negative values is:”); write_line( count_negative( temp ) ); write_line(“The largest value is:”); write_line( maximum( temp ) ); return 0; } Instructions

Leave a Reply

Your email address will not be published. Required fields are marked *