Write a c program using the fork() system

Assignment Help Basic Computer Science
Reference no: EM13168544

The Collatz conjecture concerns what happens when we take any positive integer n and apply the following 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 example, if n = 35, the sequence is 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1

Write 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 example, 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 necessary 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 necessary error checking to ensure that a positive integer is passed on the command line.

Reference no: EM13168544

Questions Cloud

Create a class named blooddata that includes fields : Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -). Create a default constructor that sets the fields to "O" and "+", and an overloaded c..
Recursive method : What will happen when the following recursive method is executed with an initial input value of 10?public int recursiveMethod(int input)
Calculate the concentration of sodium ions : Calculate the concentration (M) of sodium ions in a solution made by diluting 50.0 mL of a 0.874 M solution of sodium sulfide to a total volume of 250.0 mL
Will compute the value of each piece of clothing. : write a script in MATLAB that will compute the value of each piece of clothing.
Write a c program using the fork() system : Write 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 example, if 8 is passed as a parameter on the command line, the child process will ou..
Work out from the molar mass : An antacid tablet contains 0.1 g of magnesium hydrogencarbonate, Mg(HCO3)2. What mass of stomach acid, HCl, will it neutralise? The reaction between Mg(HCO3)2 and HCl is: Mg(HCO3)2 + 2HCl → MgCl2 + 2CO2 + H2O
What mass of carbon monoxide in grams is present : What mass of carbon monoxide in grams is present in a room measuring 8.5 12.0 18.4 ft ?
Data validation refers to checking the content : Data validation refers to checking the content of data to ensure that it satisfies certain rules, known as constraints. For example, the employee name should never be omitted in the employee table, and the delivery date should be after (greater th..
Which volume of gas decomposition one mole of sodium azide. : Sodium azide, NaN3 , is made for use in car 'air bags'. When this compound is heated to 300 degrees celsius, it rapidly decomposes into its elements.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Explaining options to begin troubleshooting

Which two options should you use to begin troubleshooting?

  Explaining difficulties in managing information resources

Considering difficulties in managing information resources, explain in scholarly detail why risk management must involve in the following elements to include threats,

  Create memo for management-accounting information systems

Create a memo to your management in which you address significance of accounting information systems. Give some main features of accounting information system.

  Describe findings after conducting internet search for cde

The network administrator mentions that other ".cde" files have been sent through an FTP server to another site. Describe your findings after conducting an Internet search for ".cde" files.

  Differentiating conventional decision support system and es

A major difference between a conventional decision support system and an ES is that the former can explain a "how" question whereas the latter can also explain a "why" question.

  What role to assign to four workstations

What role (or roles) would you assign to each of the four workstations and any other equipment you recommend? What type of upgrades, if any, might the workstations require to make your solution work?

  From time to time words become obsolete

One more requirement, from time to time words become obsolete. When this happens, such word must be removed from the dictionary. Your program must account for this also.

  Express problem as ilp constraints

Each will receive exactly 7. Additionally, each individual must receive the same quantity of wine. Express the problem as ILP constraints, and find a solution.

  Hardware and system software qualify as infrastructure

What is infrastructure? In what was do hardware and system software qualify as infrastructure? What basic strategic planning questions should be addressed with respect to infrastructure?

  Write a version of sum pairs i that sums each component

Using SML write a version of sumPairs that sums each component of the pairs separately, returning a pair consisting of the sumof the first components and the sum of the second components

  Recognize interface metaphor to use for conceptual design

For conceptual design (architectural or high-level), recognize the interface metaphor to use, interaction type(s) to employ, and interface type(s) to follow. For each of these, make sure to describe why you select what you did.

  How computer tackles loss of power to limit loss

In short talk about how computer tackles loss of power to limit loss of all work that has been done. In discussion, you may wish to consider concepts like: multiprogramming, time-sharing, time-slice, and interrupts.

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