What output will be at Line X, Line Y and Line Z? #include #include #include #define
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
What output will be at Line X, Line Y and Line Z? #include #include #include #define
What output will be at Line X, Line Y and Line Z? #include <sys/types.h> #include <stdio.h> #include <unistd.h> #define SIZE 4 int nums[SIZE] = {-6, 12, -18, 24); int main() { int i; pi_t pid fork(); if (pid == 0) { for (i = 0; i < SIZE; i++) { nums = nums* i-8; = printf("CHILD: %d ",nums); /* LINE X */ pi_t pid_1= fork(); if(pid_1= = 0){ for (i = 0; i < SIZE; i++) { nums *= i+4; printf("CHILD: %d ", nums); /* LINE Y */ } else if (pid > 0) { wait(NULL); for (i = 0; i < SIZE; i++){ nums + = 4i; printf("PARENT: %d ",nums); /* LINE Z*/} } return 0; } } }
a. False What resources are used when a thread is created? How do they differ from those used when a process is created? [2] Explain the role of the init (or systemd) process on UNIX and Linux systems in regard to process termination. [2]