Prepare a c program using the fork() system call

Assignment Help C/C++ Programming
Reference no: EM13707303

Question: The Collatz conjecture concerns what happens when we take any positive integer n and apply the subsequent algorithm:

n= n/2, if n is even

3 × n + 1, if n is odd

The conjecture states that when this algorithm is continually applied, all positive integers will eventually reach 1.

For case, if n = 35, the sequence is 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1

Prepare a C program using the fork() system call that generates this sequence in the child process. The starting number will be provided from the command line.

For case, if 8 is passed as a parameter on the command line, the child process will output 8, 4, 2, 1. Because the parent and child processes have their own copies of the data, it will be required for the child to output the sequence. Have the parent invoke the wait() call to wait for the child process to complete before exiting the program.

Perform required error checking to ensure that a positive integer is passed on the command line.

You need to prepare a program to make a system call - Use the c programming language to prepare this program.

Reference no: EM13707303

Questions Cloud

Establish shared-memory object between parent and child : the child process must output the sequence of numbers generated from the algorithm specified by the Collatz conjecture because the parent and child have their own copies of the data.
Write a program to implement a linear linked list : Write a C/C++ program to implement a singly linear Linked List
Function that will accept the three sides of a triangle : Create a function that will accept the three sides of a triangle (a, b, c) as scalar values, calculate the angles that correspond to these sides (alpha, beta, gamma), and return these angles to the function call in the script file.
Determine the total resistance of a number of resistors : Prepare a function that will determine the total resistance of a number of resistors that are connected in parallel.
Prepare a c program using the fork() system call : Perform required error checking to ensure that a positive integer is passed on the command line - Prepare a C program using the fork() system call that generates this sequence in the child process. The starting number will be provided from the comm..
Make a tundish model showing molten metal flowing : Make a tundish model showing molten metal flowing into a beaker kept below the tundish.
Describe process of setting the seimens pid block : Explain the process of setting the Seimens S7-12000 PID Block's status manual, to automatic. Be specific
Program that uses a library database of books : Write a Java program that uses a library database of books and patron data, as described in Exercise R22.2. Patrons should be able to check out and return books.
Write a program for keeping a course list : Write a program for keeping a course list for each student in a college. The information about each student should be kept in an object that contains the student's name and a list of courses completed by the student.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Written a code that parses through a file reading

written a code that parses through a file reading it line by line and splitting it into tokens by white space. But I want a pair of single quotes to be one token, not how many words are in it

  Consider the following schema of an online flight

consider the following schema of an online flight reservation agency.customercid lastname firstname dobflightfid

  Build a randomly generated simple substitution cipher

Design, implement and test classes in C++ Apply and implement ? overloaded? operators and functions Design and implement classes using inheritance

  Make an explicit statement of the invariant of the set class

Prepare a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, you'll need to change the interface a bit.

  It would be cool if a device was actually part

Have you ever been low on cash and couldn't go beyond a certain dollar limit when shopping? You sort of need a calculator in your head. It would be cool if a device was actually part of the cart and as you add an item into the cart it would increm..

  Write a c++ program that displays a table showing the price

write a C++ program that displays a table showing the price of silver and gold.

  Write a c++ program that would take two 3x3 matrix

Write a C++ program that would take two 3x3 matrix and outputs the results of adding, subtracting and multiplying two matrices. Create at least three functions: one that performs addition,

  In c++, write a program that calculates 10,000 tries.

In C++, write a program that calculates 10,000 tries. These tries are based upon a rat trying to escape from a maze. Keep adding minutes until the rat is free and when he is free that is 1 try so we need 10,000. We start by randomly generating a numb..

  Write a c program which takes a string from command line

Write a c program which takes a string from command line with mainfunction has no parameter and convert the string in upperca

  Generate mathematical problems based on the difficulty level

Generate mathematical problems based on the difficulty level selected. You must implement the following five levels of difficulty

  Program that will read in 8 numbers into an array

Write a program that will read in 8 numbers into an array. Print out the numbers from the array, then print the 2nd number, the 5th number and the last number.

  Write a corresponding if else statement

The mathematical operation max(x,y,w,z) can be represented by using the conditional expression operator, as in:  max = (x > y && x > z && x > w) ? x : ((y > z && y > w) ? y : ((z > w) ? z : w))  Write a corresponding if else statement that is equival..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd