Please I need this ASAP

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: 899603
Joined: Mon Aug 02, 2021 8:13 am

Please I need this ASAP

Post by answerhappygod »

Please I Need This Asap 1
Please I Need This Asap 1 (162.31 KiB) Viewed 53 times
Please I need this ASAP
PROGRAM DESCRIPTION: Write two C programs that demonstrate the use of fork () and execv (). PROGRAM REQUIREMENTS: A file called sum. c that does the following: ● ● ● Declare an integer array that can hold up to 10 integer values. In a for loop, initialize the integer array with the first 10 natural numbers (excluding 0). Integer 1 at index 0, integer 2 at index 1 and so forth. In a second for loop, compute the cumulative sum of the first 10 natural numbers and store it in a variable called sum. A file called sum_fork.c that does the following: Fork a child process using fork () and store the return value in a variable named pid. Using execv (), ensure that the child process executes the previously created binary, sum. Also within the child process, print the PID of the process executing instructions using getpid (). Outside of the child process section, ensure that the parent process waits for the completion of the child process using wait () and print the PID of the process executing instructions using getpid (). ● Display a message with the sum of the first 10 natural numbers using printf. Compile the program and rename the executable as sum. EXPECTED OUTPUT: $ ./a.out The sum of the first 10 integers is 55
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply