Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Cor C++ program A6p4.c (or A6p4.cpp) that accepts one command line argum

ID: 3732747 • Letter: W

Question

Write a Cor C++ program A6p4.c (or A6p4.cpp) that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 99 inclusive and store them in a 5 by 12 two dimensional integer array (i.e.int a [5] [12]). Use pthread to create n threads to update all array numbers according the following rule: if a number is even increment it by one; if a number is odd decrement it by one. You should divide this update task among the n threads as evenly as possible. Print the array before the update and after the update separately as 5 by 12 two dimensional arrays. (35 points) (Note: if you do not use pthread to divide the update task among the threads, you will get zero points.)

Explanation / Answer

ANS:-

Given that,

we have to write a Cor C++ program A6p4.c (or A6p4.cpp) that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 99 inclusive and store them in a 5 by 12 two dimensional integer array (i.e.int a [5] [12]). Use pthread to create n threads to update all array numbers according the following rule: if a number is even increment it by one; if a number is odd decrement it by one. You should divide this update task among the n threads as evenly as possible. Print the array before the update and after the update separately as 5 by 12 two dimensional arrays. (35 points)

(Note: if you do not use pthread to divide the update task among the threads, you will get zero points.)

PROGRAM:-

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote