Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Language = C. Please give an answer with an explanation. int main (int argc, cha

ID: 3708204 • Letter: L

Question

Language = C. Please give an answer with an explanation.

int main (int argc, char "argv) {

int i;

int pid;

pid = fork();

pid = fork();

printf(“I am a Spawned program ”);

return(0);

                }

How many times will the text “I am a spawned program” be printed?

a) 1        b) 2       c) 3         d) 4        0) none of the above

int main (int arge, char "argv) nt i in: pid, char 'argv1tl ('printOne", NULL) pid fork() execvp( printone", argvi) pid - fork(), printf"I am a spawned programln"). return(0) How many times will the message "I am a spawned program be printed a) o b c)2 d)3 e)4 How many times wilf the message "Il is a nice day be printed a) 0 b c)2 d)3 )4 How many processes will be created a) 0 b) 1 c)2 d) 3 e) 4

Explanation / Answer

ANSWER: Here before your message there are two fork() system calls which create 4 child processes so here this message will print 4 times, so here option(D) will be correct.