> For the complete documentation index, see [llms.txt](https://eric-lo.gitbook.io/lab4-process/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eric-lo.gitbook.io/lab4-process/lets-fork/exercises.md).

# Exercises

Take a note of the program below. It has several `fork()` and `printf()`. How many `A`, `B` and `C` will be printed?

```c
/* LetsFork/fork_ex.c */
#include <stdio.h>
#include <unistd.h>
int main(int argc,char *argv[]){
    printf("A\n");
    fork();
    printf("B\n");
    fork();
    printf("C\n");
    return 0;
}
```

How many `A`, `B` and `C` will be printed?

(a). A: 1 time, B: 2 times, C: 2 times

(b). A: 1 time, B: 2 times, C: 4 times

(c). A: 1 time, B: 1 time, C: 2 times

(d). A: 1 time, B: 2 times, C: 3 times
