Build two programs. Program one makes a named pipe and reads from standard input
ID: 3828965 • Letter: B
Question
Build two programs. Program one makes a named pipe and reads from standard input pairs of integers, then writes the sum and subtraction of each pair to the named pipe. Program two wiill read from the named pipe pairs of integers, and print to standard out the original pair of integers program one read. The math operations for reading from the named pipe are a + b = (a - b)/2 and a - b = (a + b) / 2. Program two will terminate when it reads a pair of 0 and return the total numbers of integer pairs it read.
Explanation / Answer
Program 1:
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/types.h>
int main()
{
int a,b,c;
int a=1;
int b=2;
c=(a+b)=(a-b)/2;
if (result=0)
perror(“terminate”);
exit();
}
Program 2:
#include<stdio.h>
#include<fcntl.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<sys/types.h>
{
int a,b,c;
int a=1;
int b=2;
c=(a-b)=(a+b)/2;
if (result=0)
perror(“terminate”);
exit();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.