Question: You are required to trace the following program where the input provided to the scanf is your student number. You must draw the process tree,

You are required to trace the following program where the input provided to the scanf is your student number. You must draw the process tree, identify a potential output and clearly state if the output could be different. int num; scanf("%d", &num); int n1; int pid = -1; for(int i=0; i<2; i++) { if(pid) { n1 = num%10; pid = fork(); num /= 10; } } for(int i=0; i<3; i++) { if(i == 0 && n1%2) { if(!fork()) { printf("X"); return 0; } } printf("%d", num); num /= 10; }

Step by Step Solution

3.41 Rating (148 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is the flow of the program int num s... View full answer

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 Computer Engineering Questions!