Question: Using C programming, create a if-else insides a for loop that will loop 5 times to get the output below. Implement a program that will
Using C programming, create a if-else insides a for loop that will loop 5 times to get the output below.
Implement a program that will communicate the value of an integer x, between processes.
x will start with the value 19530, and you must print that value. Then you will loop 5 times where in each loop: the child goes first and subtracts 5 from x, then parent then divides x by 5 and both processes print who they are an their result of x after the operation. If you use a and not shared memory, then during each iteration of the loop both process must get the value of x from the file, and store the resulting value of x to the file.
wait() is a required function call, so you need to create a new process, and terminate it each time throught the loop.
fork () and wait() are required
Output:

x 19530 TERATION 1 Child x19525 Parent: x=3905 TERATION 2 Child: x=3900 Parent: x = 780 TERATION 3 Child x775 Parent:x 155 ITERATION 4 Child: x= 150 Parent: x=30 ITERATION 5 Child: x=25 Parent: x=5 Listing 1: Screen Output x 19530 TERATION 1 Child x19525 Parent: x=3905 TERATION 2 Child: x=3900 Parent: x = 780 TERATION 3 Child x775 Parent:x 155 ITERATION 4 Child: x= 150 Parent: x=30 ITERATION 5 Child: x=25 Parent: x=5 Listing 1: Screen Output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
