Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. - Get n from as a command line a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. - Get n from as a command line a

Post by answerhappygod »

Write A C Code To Perform Vector Arithmetic Define 3 Vectors A 100 B 100 C 100 Get N From As A Command Line A 1
Write A C Code To Perform Vector Arithmetic Define 3 Vectors A 100 B 100 C 100 Get N From As A Command Line A 1 (195.4 KiB) Viewed 31 times
Write a C code to perform vector arithmetic: - Define 3 vectors A[100], B[100], C[100]. - Get n from as a command line argument. Example if n=10, then /vector 10), and create n processes. (n will be one of Divisors of 100). - Get operation from user: add, sub. Each process will create a number of threads. Number of threads per process = 100/(10*number of processes). Perform the operation on a chunk of the vector, for example, if n = 10, each process will create (100/10*10=1) 1 thread to add sub 10 elements. Use execl to run the add or sub programs Parent should print A,B,C in a file. (vourname.txt) For example, n =5, operation=sub Partition work equally to each process: PO create (100/10*5=2) 2 threads → Threadoo will executes 4[0:9] = B[0:91 - C [0:9) Threadol will executes A[10:19] = B[10:19) - C[10:19] PI create (100/10*5=2) 2 threads → Thread 10 will executes A[20:29] = B[20:29) - C [20:29) Thread! I will executes A[30:39] = B[30:39 - C [30:39] and so on. no synchronization is required For example, if the output file named (vector) the output will be like this -/vector 5 B[100]={1,2,3,4,3,2,3,3,.....etc..} C[100]={4,2,9,4,1,2,3,3,.....etc..} Enter the Operation for Add enter 1 for Sub enter 2:2 5 processes created, each process creates 2 threads. Parent process print A,B,C in. (Ahmad.txt)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply