Question: Second image is project 1-2 for your reference. The Collatz conjecture concerns what happens when we take any positive integer n and apply the following

 Second image is project 1-2 for your reference. The Collatz conjectureconcerns what happens when we take any positive integer n and apply

Second image is project 1-2 for your reference.

The Collatz conjecture concerns what happens when we take any positive integer n and apply the following algorithm: 11 = 1/2, if n is even 3 x n +1, if n is odd The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1. For example, if n = 35, the sequence is 35, 106, 53, 160, 80, 40, 20, 10,5, 16, 8, 4, 2, 1. You have created a C/C++ program that creates a child process that prints out a message in Project 1-2. In this project (Project 1-3), you should modify the code of Project 1-2 such that the child process generates this sequence of numbers instead of simply printing out a message. The child process should take the user input n from the command line and print out the sequence of numbers. For example, >user input: 35 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1. At the same time, make the parent invoke the wait() call to wait for the child process to complete before exiting the program. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include #include #include Dint main() { int n = fork(); if (n > 0) //when n is not 0, parent { wait(NULL); std::cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!