Make a copy of the pthreads_skeleton.cpp program and name it pthreads_p2.cpp 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.

Respuesta :

Answer:

The solution code is as follows:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.    int myArray [10] = {};
  6.    
  7.    int i;
  8.    for( i = 0; i < 10; i++ )
  9.    {
  10.        cout <<"Enter an integer: ";
  11.        cin>> myArray[i];
  12.    }
  13. }

Explanation:

Firstly, we initialize a 10-elements array, myArray (Line 7) with no values.

Next, we create a for-loop (Line 10). Within the loop, we prompt user to enter an integer and assign the input value to the current element of myArray (Line 12-13).