Question: Consider the program below: #include #include int counter = 0; int main() { int i; for (i=0; i <2; i++) { fork(); counter++; printf(counter =

Consider the program below:

#include

#include

int counter = 0;

int main()

{

int i;

for (i=0; i<2; i++) {

fork();

counter++;

printf("counter = %d ", counter);

}

printf("counter = %d ", counter); /* LINE Y */

return 0;

}

Please answer the questions 3a-3c below. In one line for each part, explain the reason why.

3a. What is the total number of lines that will be printed and why?

____________________________________________________________________________

3b. What is printed in the first line and why?

_____________________________________________________________________________

3c. What is printed in the last line (LINE Y) and why?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!