Exercises

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

/* 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: 1 time, B: 2 times, C: 2 times A: 1 time, B: 2 times, C: 4 times A: 1 time, B: 1 times, C: 2 times A: 1 time, B: 2 times, C: 3 times