Question: Assuming the following C code snippet, select all statements that are correct: int main ( ) { int n , j , k; k =

Assuming the following C code snippet, select all statements that are correct:
int main(){
int n, j, k;
k =0;
for ( j =0; j <4; j++)
k = k + j;
n = fork();
if ( n ==0){// or (! n )
k =999;
j = j -1;
}
else
n = k %3;
printf("%d %d %d
", n, j, k);
return 0;
}
Group of answer choices
The print statement belongs to the child process only
Variables n, j, k exist in both processes
On the last line of the code, the values of n, j, k variables are different in the parent and different in the child
The if statement indicates the parent process
fork function is called in order to create a child process by cloning the parent process in a new memory space

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!