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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started