Modify this code to use multiple threads with the same data 1.Modify the main function to implement a loop that reads 10 integers from the console (user input) and stores these numbers in a one-dimensional (1D) array (this code will go right after the comment that says “Add code to perform any needed initialization or to process user input”). You should use a global array for this. 2.Implement a separatepthread function function for each one of the following operations: a.Count and print out how many of the entered numbers are negative. This function must be named countNegatives b.Calculate and print the average value of all the numbers entered. This function must be named average c.Print the numbers in reverse order from the order in which they were entered. This function must be named reverse 3.Modify the main function to create one pthread for each one of the functions that you implemented in (3) above (this code will go between the comment that says “TODO: Modify according to assignment requirements” and the “if (rc)” check). Compile your program and run it several times. If the output of your program is garbled, you may need to add a small delay in between creating the next thread. #include #include using namespace std; void *routineName(void *arg) { // TODO: Add code that implements // the thread\'s functionality cout << \"Thread is running...\" << endl; return 0; } int main() { pthread_t id; int rc; int ints; for(int x; x<10; x++) { cout << \"Enter Integer: \" <> } rc = pthread_create(&id, NULL, routineName, NULL); if (rc){ cout << \"ERROR; return code from pthread_create() is \" << rc << endl; return -1; } pthread_exit(0); } Solution #include #include #include using namespace std; int ints[10]; //Method to count negatives in the input array void *countNegatives(void*){ int count = 0; for(int i=0;i<10;i++){ if(ints[i]<0){ count++; } } cout<<\"Number of negatives: \"<=0;i--){ cout<> ints[x]; } //Creating pthread to countNegatives rc = pthread_create(&t1, NULL, countNegatives, NULL); if(rc){ cout << \"Error:unable to create thread,\" << rc << endl; } //Adding delay sleep(1); //Creating pthread to compute average rc = pthread_create(&t2, NULL, average, NULL); if(rc){ cout << \"Error:unable to create thread,\" << rc << endl; } //Adding delay sleep(1); //Creating pthread to print in reverse rc = pthread_create(&t3, NULL, reverse, NULL); if(rc){ cout << \"Error:unable to create thread,\" << rc << endl; } //Adding delay sleep(1); void* status; //waiting for t1 to join rc = pthread_join(t1,&status); if(rc){ cout << \"Error:unable to join,\" << rc << endl; } //waiting for t2 to join rc = pthread_join(t2,&status); if(rc){ cout << \"Error:unable to join,\" << rc << endl; } //waiting for t3 to join rc = pthread_join(t3,&status); if(rc){ cout << \"Error:unable to join,\" << rc << endl; } pthread_exit(0); }.