int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, "Usage: forkloop <iterations>\n");
        exit(1);
    }

    int iterations = strtol(argv[1], NULL, 10);
    printf("ppid = %d, pid = %d\n", getppid(), getpid());
    
    for (int i = 0; i < iterations; i++) {
        int n = fork();
        if (n < 0) {
            perror("fork");
            exit(1);
        }
        if (n == 0){
            break;
        }
        printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i);

    }
    wait(NULL);
    return 0;
}

the command line argument is the number of forks done by this program. Have it such that all the forks have different process ids but are forked from the same parent (have the same ppid).