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

  Write a program that skip s leading whitespace character

a) Write a program that skip s leading whitespace character s in each line of the pro vided data file CPPHumor .txt . Save the results in a new file

  Chess program, enable a monitoring component

Given a chess program, enable a monitoring component to switch planning algorithms at runtime, based on the opposing player's style and response time.

  Prepare a program that uses at least two functions

Prepare a program that uses at least two functions that can be called from your main.

  The factorial of a positive integer n, denoted by n!

Write a program that computes the sequence of factorial values: 1! = 1, 2! = 2, 3! = 6, 4! = 24, 5! = 120, 6! = 720, ....

  Design in c a unix utility program gasp

Design in C a Unix utility program gasp. Command gasp [options] STRING FILE... must read listed files (FILE...) and copy each line from input to stdout if it contains STRING.

  Create a template class

Create a template class, SVector, that implements a constructor

  Multiple heaps

Create an application that has two heaps. Place a linked list into each heap. Select one hundred random numbers. Place each of the random numbers into each heap - CSI 345 - Spring 2014 S2

  Write c function to sort one dimensional integer array

Consider the values sorted in the array. Sort it in ascending order using Bubble sort technique showing all iterations: write C function to sort one dimensional integer array in ascending order.

  Program that stores a series of numbers in a binary tree

Write a program that stores a series of numbers in a binary tree

  Two for loops that will calculate the sum of all even number

Write a program using two for loops that will calculate the sum of all even numbers between 2 and 100,

  Write a c program that reads in five numbers

Q1. (Bar Chart /Histogram printing) Write a C program that reads in five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the numb..

  The program should support a ''new'' feature

Write a GUI program that represents a simple Notepad clone. The program should support a 'new' feature that clears the text buffer, a save feature that writes to a file using a PrintStream

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