Description:
The exercise 4 creates a process tree just like exercise 1. But the processes created are all alive and do something.
For your reference, here is my code for exer1. You can adapt it for this exercise.
First you have to create pipes between processes.
Then, after the tree is built, the root read from stdin a char which denotes the root of a subtree. The root process passes it down to its children so that just the process belonging to the designated subtree print messages. And the messages are shown in pre-order.
  For examples:

$ ./a.out abhefcigd hefbigcda
a            <------------------------------------------- read by root process
hello, i'm a, my pid is 21985, and my parent is 21890
hello, i'm b, my pid is 21986, and my parent is 21985
hello, i'm h, my pid is 21987, and my parent is 21986
hello, i'm e, my pid is 21989, and my parent is 21986
hello, i'm f, my pid is 21992, and my parent is 21986
hello, i'm c, my pid is 21988, and my parent is 21985
hello, i'm i, my pid is 21990, and my parent is 21988
hello, i'm g, my pid is 21993, and my parent is 21988
hello, i'm d, my pid is 21991, and my parent is 21985
b            <------------------------------------------- read by root process
hello, i'm b, my pid is 21986, and my parent is 21985
hello, i'm h, my pid is 21987, and my parent is 21986
hello, i'm e, my pid is 21989, and my parent is 21986
hello, i'm f, my pid is 21992, and my parent is 21986
e
hello, i'm e, my pid is 21989, and my parent is 21986
c
hello, i'm c, my pid is 21988, and my parent is 21985
hello, i'm i, my pid is 21990, and my parent is 21988
hello, i'm g, my pid is 21993, and my parent is 21988
d
hello, i'm d, my pid is 21991, and my parent is 21985
q            <------- q is for quit !
$