Question: The code of a program as follows. #include #include #include #define SIZE 5 int nums[SIZE] = [0,1,2,3,4}; int main() { int i; pid t
The code of a program as follows. #include #include #include #define SIZE 5 int nums[SIZE] = [0,1,2,3,4}; int main() { int i; pid t pid; pid= fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { nums[i] = -1; printf("CHILD: %d ", nums[i]); /* LINE X */ } } else if (pid > 0) { wait(NULL): for (i = 0; i < SIZE; I++) printf("PARENT: %d ", nums[i]); /* LINE Y*/ } return 0; } Show what the output will be at lines X and Y. Line X: CHILD: CHILD: CHILD: CHILD: CHILD Line Y: PARENT: PARENT: PARENT: PARENT: PARENT
Step by Step Solution
There are 3 Steps involved in it
The code provided is a C program that makes use of the fork system call to create a new process Here ... View full answer
Get step-by-step solutions from verified subject matter experts
