PTJL14 The Asker · Computer Science
this is in c++ and in codeblocks, i have no idea how or where to start with this, please explain in the best way possible and show me what you did. also pictures of the outputs would be nice:) thank you!!
Transcribed Image Text: Task Description: You have been given a very simple program that performs basic operations (addition, subtraction, editing) on two randomly generated integer vectors. All functionality has been included in main, causing code segments to be repeated as well as diminishing the readability Rewrite the program by grouping calculations and related operations into functions. In particular, your program should include the following functions • InitializeVectors: This is a void function that initializes the two vectors by random numbers. Inside this function, the user will be prompted to enter the maximum random number. After the vectors have been populated with random numbers, print the vectors side by side. The parameters are the two arrays and their size. • EditVector. This is a void function that allows the user to update a value belonging to either vector. The user specifies the vector he wants to edit, the index he wants edit, and finally the updated value. The entire vector must then be printed on the screen. You need to pass the two arrays and their sizes • Calculate Average: This is a function that returns the average value in a vector It returns a double and receives as parameters an array and its size • print Vector: A void function that takes a vector as a parameter along with its size and prints it on the screen As you introduce each function, replace the code in main( by the appropriate function call. Also, keep in mind that for some functions, any changes that occur within the function body must also be visible in main. Finally, some functions can be called within other functions. OS . GOODS Start here X main(33). #include chitalardo.h> ing pasta int main() 9 10 11 12 13 14 Tnt voor the into the root both hando o int id Wenn which to have int ceiling Werting randon numbers to pisce in to this contra int action of the per double av GetSize: coot Entiteto vectors dinsv_ite: Icin.Biltre 20 21 22 ayate (Hot cout<>Vid: i lain. fail trued_102) > Start here X als ! main(33).cpp X if (cin. fail() - true 1 ( vid! 1. Vid!-2)) 1 system("CLS"); cout<<"Invalid Input. Please Re-enter Vector Selection (1 OF 2): "; cin.clear(): cin. ignore (10000,"\n'); goto get Vector: 1 11 (101) for (int 10; i>v id; if (cin.fail() == true 1 (v_id ! v_id !=2) system("CLS"); cout<<"Invalid Input. Please Re-enter Vector Selection (1 or 2): ": Search Project Build Debug Fortran wxSmith Tools Tools Plugins DoxyBlocks Settings Help 499: 96: Il FSymbols main(33).cpp x cout<<"Invalid Input. Please Re-enter Vector Selection (1 or 2): cin.clear() cin.ignore (10000,"\n"); goto Get Vector: > Get Index: cout<<"Select Index to be Updated: "<>index: if(win. failt) - true index || index) (v size-1)) Start here X 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 system("CUS"): cout<<"Invalid Input. Please Re-enter index to be updated: ": cin.clear(); cin.ignore (10000, An): goto Get Index: > cout<<"Enter updated value: if(v_id = 1) -n cin>5v1 [index: for (int i=0; i< v Bize 1 cout<>v2 [index] for (int i=0; i v_size: 1) cout<>vl[index] : for (int i0; i< v_size; i++) cout<>v2 [index); for (int 10; 1Vsize: 1++) cout<
More
Transcribed Image Text: Task Description: You have been given a very simple program that performs basic operations (addition, subtraction, editing) on two randomly generated integer vectors. All functionality has been included in main, causing code segments to be repeated as well as diminishing the readability Rewrite the program by grouping calculations and related operations into functions. In particular, your program should include the following functions • InitializeVectors: This is a void function that initializes the two vectors by random numbers. Inside this function, the user will be prompted to enter the maximum random number. After the vectors have been populated with random numbers, print the vectors side by side. The parameters are the two arrays and their size. • EditVector. This is a void function that allows the user to update a value belonging to either vector. The user specifies the vector he wants to edit, the index he wants edit, and finally the updated value. The entire vector must then be printed on the screen. You need to pass the two arrays and their sizes • Calculate Average: This is a function that returns the average value in a vector It returns a double and receives as parameters an array and its size • print Vector: A void function that takes a vector as a parameter along with its size and prints it on the screen As you introduce each function, replace the code in main( by the appropriate function call. Also, keep in mind that for some functions, any changes that occur within the function body must also be visible in main. Finally, some functions can be called within other functions. OS . GOODS Start here X main(33). #include chitalardo.h> ing pasta int main() 9 10 11 12 13 14 Tnt voor the into the root both hando o int id Wenn which to have int ceiling Werting randon numbers to pisce in to this contra int action of the per double av GetSize: coot Entiteto vectors dinsv_ite: Icin.Biltre 20 21 22 ayate (Hot cout<>Vid: i lain. fail trued_102) > Start here X als ! main(33).cpp X if (cin. fail() - true 1 ( vid! 1. Vid!-2)) 1 system("CLS"); cout<<"Invalid Input. Please Re-enter Vector Selection (1 OF 2): "; cin.clear(): cin. ignore (10000,"\n'); goto get Vector: 1 11 (101) for (int 10; i>v id; if (cin.fail() == true 1 (v_id ! v_id !=2) system("CLS"); cout<<"Invalid Input. Please Re-enter Vector Selection (1 or 2): ": Search Project Build Debug Fortran wxSmith Tools Tools Plugins DoxyBlocks Settings Help 499: 96: Il FSymbols main(33).cpp x cout<<"Invalid Input. Please Re-enter Vector Selection (1 or 2): cin.clear() cin.ignore (10000,"\n"); goto Get Vector: > Get Index: cout<<"Select Index to be Updated: "<>index: if(win. failt) - true index || index) (v size-1)) Start here X 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 system("CUS"): cout<<"Invalid Input. Please Re-enter index to be updated: ": cin.clear(); cin.ignore (10000, An): goto Get Index: > cout<<"Enter updated value: if(v_id = 1) -n cin>5v1 [index: for (int i=0; i< v Bize 1 cout<>v2 [index] for (int i=0; i v_size: 1) cout<>vl[index] : for (int i0; i< v_size; i++) cout<>v2 [index); for (int 10; 1Vsize: 1++) cout<