(Solved) : Write Collatz Program Output Collatz Conjecture Sequence Refer Https Enwikipediaorg Wiki C Q35557996
Write a ‘Collatz’ program tooutput the Collatz-Conjecturesequence (Refer to:https://en.wikipedia.org/wiki/Collatz_conjecture)
Problem Statement: Implementthe program by POSIX sharedmemory and structure yourprogram by the producer-consumermode. The program should bewritten in two separate files‘Collatz-Producer.c’ and‘Collatz-Consumer.c’.
(1) This program should workas follows:
(a) The producer processwrites the contents of thesequence to the shared-memoryobject. Its mainsteps are listed asfollows:
- Perform error checking toensure that the input isvalid.
- Establish the shared-memoryobject.
- Writes the contents of theshared memory.
(b) The consumer processoutputs the sequence when theproducer completes. Its mainsteps are listed asfollows:
- Open the shared-memory object.
- Output the contents of the shared memory.
- Remove the shared-memory object.
(2) Here is a sample run tohelp you with debugging:
Producer: Writingthe sequence to the shared-memoryobject is done!
Consumer: Theoutput sequence is: 35,106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1