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

  Write mergesort code for data instead of as array

Write mergesort code for data instead of as array - which takes a linked list of integers, as in the bubblesort example code. The decclaration of the struct listnode is the same as in the bubblesort on lists example.

  Gcd between two positive integer numbers

Write a C++ code for calculating the GCD (Greatest Common Divisor) between two positive integer numbers. You  should  use Euclid's  original  subtraction  based  GCD algorithm ( not  using  modulo operator). You should write a function following t..

  Write a header for the function named subtract

Write a header for the function named subtract. Subtract returns nothing and has one double parameter named num.

  Write program to calculate net pay for factory worker

Write and run a program in C++ that calculates the net pay for a factory worker. The program prompts the user for skill level and hours worked, as well as appropriate insurance and retirement options for the employee's skill.

  You are to add mean, standard deviation

You are to add mean, standard deviation, and insert in order functionality to your statistics list program. Insert in order means that you will add a function called find_index that will locate the place in the array that a new value should be ins..

  Output of the given c++ code

What is the output of the given C++ code - You need to find out the output of the given code.

  Displays columns titled "name", "quantity", "price", value

Write a program that displays columns titled "Name", "Quantity", "Price", and "Value". The fourth column contains the result of multiplying each item's quantity by its price. In addition, the program should calculate and display the total value of th..

  Assignment 1write a program using vectors and iterators

assignment 1write a program using vectors and iterators that allows a user to maintain a personal list of dvd titles.

  Write an application that reads the user''s weight

Write an application (BMICalc) that reads the user's weight in poinds and height in inches, then calculates the Body Mass Index.

  Write c program that prompts for variable number of integers

Write a C program that prompts for a variable number of integers, adds them up, averages them, and prints out the average.

  Write a c++ program to first find ''n'' fibonacci numbers

Write a C++ program to first find 'N' Fibonacci numbers and then display only the "even" Fibonacci numbers in "descending order" as output.

  Write a program to determine how long ball moves

Using the v2 form of drag, write a program to determine how long (sec.) and how far (m) a 150 gram ball whose radius is 3.5cm would fall before it reached 75% of its terminal velocity.

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