Answered! What is displayed to the terminal by the following c code: int x = 0;//global variable int y – 2;//global variable void…

Question 7 What is displayed to the terminal by the following C code: int x e, I global variable int y 2, global variable void main if (fork() e) else if (x 1) (*d n, y); printf 2 O 1 3 12.5 pts

What is displayed to the terminal by the following c code: int x = 0;//global variable int y – 2;//global variable void main() { if (fork() = = 0) { y – l; > else { x – 1; > if (x = = 1) { printf(“% dn”, y); } } 2 0 1 3

Expert Answer

 Answer is 2(Option A)

In the above code, a child process is created, fork() returns 0 in the child process and positive integer to the parent process.

So if loop not executed else loop execute x is initialized with 1. and then if(x==1) then y printed. Y is initialized with 2.

So the answer is: 2

Still stressed from student homework?
Get quality assistance from academic writers!