✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Select the correct output order of the following program:
1 #include<stdio.h>
2 #include<unistd.h>
3 #include<sys/wait.h>
4
5 int main() {
6 int pid;
7
8 printf( "cat\n" );
9 pid = fork();
10
11 if ( pid == 0 ) {
12 printf( "bird\n" );
13 execlp( "ls", "ls", NULL );
14 pid = fork();
15 printf( "lizard\n" );
16 }
17 else {
18 wait(NULL);
19 pid = fork();
20 if ( pid == 0 )
21 printf( "horse\n" );
22 printf( "dog\n" );
23 }
24 printf( "goat\n" );
25 }