Question: (50 pts) Write a Cor C++ program A6p2.c[pp] that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate

 (50 pts) Write a Cor C++ program A6p2.c[pp] that accepts one

command line argument which is an integer n between 2 and 4

(50 pts) Write a Cor C++ program A6p2.c[pp] that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 39 inclusive and store them in a 5 by 12 two dimensional integer array (eg,int a[5][12] ;). Use pthread to create n threads to convert all 60 array elements modulo 11 (i.e, take the remainder after division by 11) in place. You should divide this update task among the n threads as evenly as possible. Print the array both before and after the update separately as 5 by 12 matrices. Hint: it is dangerous to have code to print messages in your thread function(s). Note: if you do not use pthread to divide the update task among the threads, you may get zero points. A sample run of the programs in 1 and 2 is shown below. You do NOT need to submit screen shots. Instead submit your source files. [kwang@computer ll-/work/]$ ./A6p1 3 60 using 3 threads to handle 60 chars. original random upper case string: RUIQWCXXBFXVZFJDBWTSIBFIMMIJNRKENUUJZUIABIYANHFQDZINCPVOCGAP off-by-one lower case string: syirxdxx.cgywagkecxuticginnkkeslfoxykavibsizboigreaiodawpdhka [kwang@computer I-/work/]$ ./A6p2 4 using 4 threads. original array: 33 36 9 30 1 29 14 16 7 34 6 18 14 2 34 11 18 11 6 17 34 33 16 35 26 11 17 13 27 39 22 21 24 19 11 25 9 24 29 15 7 35 21 9 25 16 20 3 26 14 19 9 7 24 4 21 34 9 33 22 updated array: 0 3 9 8 1 7 3 5 7 1 6 7 3 1 0 7 0 6 6 1 0 5 2 4 6 2 5 6 0 10 2 8 0 3 9 2 7 4 7 2 10 9 3 5 9 3 4 38 9 7 2 4 4 10 1 9 0 0 ON WWN (50 pts) Write a Cor C++ program A6p2.c[pp] that accepts one command line argument which is an integer n between 2 and 4 inclusive. Generate 60 random integers between 1 and 39 inclusive and store them in a 5 by 12 two dimensional integer array (eg,int a[5][12] ;). Use pthread to create n threads to convert all 60 array elements modulo 11 (i.e, take the remainder after division by 11) in place. You should divide this update task among the n threads as evenly as possible. Print the array both before and after the update separately as 5 by 12 matrices. Hint: it is dangerous to have code to print messages in your thread function(s). Note: if you do not use pthread to divide the update task among the threads, you may get zero points. A sample run of the programs in 1 and 2 is shown below. You do NOT need to submit screen shots. Instead submit your source files. [kwang@computer ll-/work/]$ ./A6p1 3 60 using 3 threads to handle 60 chars. original random upper case string: RUIQWCXXBFXVZFJDBWTSIBFIMMIJNRKENUUJZUIABIYANHFQDZINCPVOCGAP off-by-one lower case string: syirxdxx.cgywagkecxuticginnkkeslfoxykavibsizboigreaiodawpdhka [kwang@computer I-/work/]$ ./A6p2 4 using 4 threads. original array: 33 36 9 30 1 29 14 16 7 34 6 18 14 2 34 11 18 11 6 17 34 33 16 35 26 11 17 13 27 39 22 21 24 19 11 25 9 24 29 15 7 35 21 9 25 16 20 3 26 14 19 9 7 24 4 21 34 9 33 22 updated array: 0 3 9 8 1 7 3 5 7 1 6 7 3 1 0 7 0 6 6 1 0 5 2 4 6 2 5 6 0 10 2 8 0 3 9 2 7 4 7 2 10 9 3 5 9 3 4 38 9 7 2 4 4 10 1 9 0 0 ON WWN

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!