Create a C program that forks itself. * * One part will ask the user to enter a number. * The program will then use a pipe to pass that number to the copy of * itself that is running. * * The copy will then add 1 to the number that it has been passed. * It will then pass the number back to the original program. * * The original program will then print out the number that it has * received. * * Run this program for the following inputs: 500, -1, 7 #include #include #include // Provides definition of "fork" int main(void) { return 0; }
AHPA #13 - The Adding Machine
*
* You have decided that what the world needs is a better adding machine * and gosh darn it, you are going to create it!
*
* Create a C
*
* One part will ask the user to enter a number.
* The program will then use a pipe to pass that number to the copy of
* itself that is running.
*
* The copy will then add 1 to the number that it has been passed.
* It will then pass the number back to the original program.
*
* The original program will then print out the number that it has
* received.
*
* Run this program for the following inputs: 500, -1, 7
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h> // Provides definition of "fork"
int main(void) {
return 0;
}
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 6 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)