Please I need this ASAP
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
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