Child process to take the role of the number guesser

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

You must implement a simple numbers guessing game. Write a program that allows for guessing a number. In reality, you would have somebody think of a number between 1 and 1000. Then you ask: "Is this number bigger than 512?" The person might answer: "Yes", in which case you add 256 (which is half of 512) to 512 -> 768. So, you ask: "Is this number bigger than 768?" The person might say "No". So you subtract 128 (which is half of 256) from 768, which is 640 etc. until you reach the number the person thought of. I hope you see the algorithm behind this game by now: it takes 10 questions to find any number between 1 and 210-1.

Write a program in C that takes a number between 1 and 1024 as input on the command line, and then forks a child process to take the role of the number guesser. The parent process will take the role of the person who has the number, answering the questions as explained above. Both processes communicate using (unnamed) pipes. NOTE: the Child cannot "look" at or use the number input to the parent via the commandline.

You must print out all intermediate results, i.e. the "Yes" and "No", as well as the questions "Is the number ...".

Reference no: EM13165678

Questions Cloud

Supposed to swap numbers : The program is supposed to swap numbers, but I am stuck something is wrong! It does not swap them it repeats the second number, please help to fix! Thanks, this is in C++.
The imperial system of measurements : The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.
What do the loops print : What do the following loops print? Work out the answer by tracing the code, not by using the computer. a. int s = 1; for (int n = 1; n
The ieee 754 single precision binary representation : What would be the IEEE 754 single precision binary representation of the floating point value -314159265. 3589 ? Express your final answer as an 8-hex-digit number and explain how your answer was obtained for full credit.
Child process to take the role of the number guesser : Write a program in C that takes a number between 1 and 1024 as input on the command line, and then forks a child process to take the role of the number guesser
Assume that a student table in a university : Assume that a student table in a university database has an index on StudentID (the primary key). and additional indexes on Major, Age, Marital status, and HomeZipCode.
Prepare a multiple-step income statement for 2010 : Prepare a multiple-step income statement for 2010 for Howell Corporation that is presented in accordance with generally accepted accounting principles
Continuously prompts the user for a number : Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each entered amount to a conversion method that displays a breakdown of the passed amount into the fewest bills
Prepare the necessary journal entry : Prepare the necessary journal entry to update the allowance for doubtful accounts assuming that the balance prior to preparing the aging was a credit of $100,000.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Programmingto compute the volume of water in the cubic feet

Write down an algorithm (Programming in C) in order to compute the volume of water in the cubic feet, flowing through a pipe of diameter d in feet, having a velocity of v feet per second.

  Write a program which accepts the total of food and drink

Write a program which accepts the total of food and drink purchased for a restaurant bill as input. The output should be adjusted bill with a sales tax of six percent 6% and a tip (gratuity) of 15%.

  . write a segment of code that prints the number of elements

Assuming the array x has been defined as: int x[n]; for some n and that values have been assigned to all the elements. Write a segment of code that prints the number of elements between (but not including) the largest and smallest values in the array..

  Local resturant automate its breakfast billing system

Use an array , menuList, of the struct menuItemType. use an array, menuList, of the struct menuItemType. your program must contain at least the following functipons : your program must contain at least the following functipons.

  The main program should create an ifstream

For decryption, the main program should create an ifstream for the file to be decrypted. It should use the getline method of the ifstream to read lines from the file, call the encryption / decryption function with the line to be decrypted, and dis..

  Program which calculates the average and sum of the numbers

write down a program which calculates the average and sum of the numbers enter by a user.Using a While Loop

  Wave steepness is the ratio of wave height

Wave steepness is the ratio of wave height (WH) to wave length(WL) and is an indicator of wave stability. When wave steepness exceeds a 1/7 ratio; the wave becomes unstable and begins to break. Assume a data file exits with the following header

  Write a switch-case programming for calculation

How to use C++ to write a switch-case programming for calculation? Test the program for a wide range of possible inputs including division by zero and square root of negative values.

  Write a program that asks the user to enter two numbers.

Starting Out with C++ Write a program that asks the user to enter two numbers.

  Write a program that plays a tic-tac-toe game.

Using functional decomposition, write a program that plays a tic-tac-toe game.

  Write a matrix multiplication program

Write a C++, matrix multiplication program which you can instrument to monitor and measure execution time as a function of problem size. Make sure it works in Microsoft Visual Studio.

  Program to enter number of values to be processed

Write c++ statements to permit the user to enter n, the number of values to be processed; then assign the anonymous array of n double values, storing its address in doublPtr.

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