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

PLEASE DO NOT SAY THAT YOU ARE ANSWERING IF YOU ARE NOT GOING TO ANSWER! Write a

ID: 3640430 • Letter: P

Question

PLEASE DO NOT SAY THAT YOU ARE ANSWERING IF YOU ARE NOT GOING TO ANSWER!

Write a program to find the vector sum C = A + B where A, B and C are one dimensional arrays of type int and of size N (assume max value for N is 100)

The main thread should initialize A and B with random integers between 0 and 10, then creates N threads such that the ith thread calculates Ci = Ai + Bi

Finally, the main thread prints the three arrays; A, B, and C

Hint: Use the function random() to get random integers, apply mod operator (%) to make the generated random number within a range. Use srandom() function to randomize the seed, so that each execution of your program generates a distinct set of random integers.

Explanation / Answer

PS: Please rate the answer to compile: gcc -pthread filename.c #include #include #include #define MAXVALUE 100 void *add_function(int a); int A[MAXVALUE], B[MAXVALUE], C[MAXVALUE]; int main() { int i; pthread_t thread[100]; //initialize A and B for(i=0;i
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