Ask Question

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.

+3
Answers (1)
  1. 5 May, 16:35
    0
    The solution code is as follows:

    #include using namespace std; int main () { int myArray [10] = {}; int i; for (i = 0; i < 10; i++) { cout <<"Enter an integer: "; cin>> myArray[i]; } }

    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).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers