here it is. Sorry if y'all don't understand what i've added since I'm mostly doing trail and error over here.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int fd[2];
pid_t childpid;
int count = 0;
int m;
char buf[100];
pipe(fd);
if ((childpid = fork()) == -1) {
perror("fork");
exit(1);
}
else if (childpid == 0) {
dup2(fd[0], 0);
read(fd[0], buf, sizeof buf);
printf("child process: no. of multiples of 5 is %s\n", buf);
read(fd[1], buf, sizeof buf); //F
printf("child process: no. of multiples of 3 is %s\n", buf); //F
}
else if (childpid > 0) {
close(fd[0]);
dup2(fd[1], 1);
for (m = 0; m < 10001; m++)
if ((m%5) == 0)
count++;
printf("%d", count); }
else if (childpid > 0) { //F
for (m= 0; m < 10001; m++) //F
if ((m%3) == 0)
count++;
write(fd[1], buf, sizeof buf);
printf("%d", count);
}
return 0;