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

  Construct an fa (finite automata)

Construct an FA (finite automata) that accepts all binary strings with an even number of 0's and the number of 1's is a multiple of 3.

  Create an android project that contains two pages

Create an Android project that contains two pages. The button on the first page would open the second page.The first page contains a label, which states your name (Juan Ruiz) and a button states "Click to see my favorite animal".

  Creating an oracle

The clique problem itself is NP-hard. Thus you may not wish to have an oracle that runs in exponential time. Consider approach to approximate the solution.

  A group of children play a scavenger

A group of children play a scavenger hunt under a time limit of two hours. Points are given to the amount of items found, the type of item does not matter.

  Explain cyberspace arena for human social interaction

Do you believe cyberspace is a whole new arena for human social interaction, or is it simply one more tool which humans put to remarkable range of uses without actually changing in any fundamental way?

  Floating point numbers in scientific notation

Floating point numbers in scientific notation represents numbers as a base number and an exponent. For examples: 2E3, 2.0E12, 3.14E+12, 3.14E-12. Give a grammar that generates floating point numbers. Use your grammar to derive 3.14E+12.

  Design an asynchronous base 14 counter

Design an asynchronous base 14 counter that counts through the natural binary sequence from 0 (0000) to 13 (1101) and then returns to zero on the next count.

  Hierarchy chart and then plan the logic

Draw the hierarchy chart and then plan the logic for a program needed by the sales manager of The Henry Used Car Dealership. The program will determine the profit on any car sold

  What do you consider the two most important software innovat

identify and describe what you believe to be the two most important hardware innovations.

  Creating data encryption standard for ibm

Let us start off with once widely used Data Encryption Standard (DES) which was created by International Business Machines (IBM).

  Develop an interface evaluation questionnaire

Develop an interface evaluation questionnaire that contains 20 generic questions that would apply to most interfaces.

  To perform queries

To perform queries on a relational database system using SQL? To demonstrate an advanced knowledge of stored procedures, stored functions and triggers.

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