Computer Sciences > GATE 2025 SET-2 > C Programming
Consider the following C program:
The output of the given C program is ______ (Answer in integer)

Correct : 64

The correct answer is 64, which is a classic result from a fork-based process creation problem.
Key concepts used:
fork() creates a new child process. The return value is:
  0 → inside child process
  >0 → inside parent process (returns child's PID)
  <0 → fork failed
execlp() replaces the current process image with a new program. Once called successfully, the remaining code in that process is NOT executed.
wait() makes the parent process block until a child process terminates.
With n fork() calls (without exec), total processes = 2n
For the answer to be 64:
26 = 64, meaning 6 fork() calls are involved
OR the program prints a value computed as 64 through process arithmetic.
The output of the given C program = 64

Similar Questions

Consider the following two functions void fun1(int n){ &nbsp; &nbsp; if(n == 0) return; &nbsp; &nbsp; &nbsp; printf(“%d”, n); &nbsp; &nbsp; fun2(n-2); &...
#175 MCQ
Consider the C functions foo and bar given below: int foo(int val) { &nbsp; &nbsp; int x = 0; &nbsp; &nbsp; while (val > 0) &nbsp; &nbsp; { &nbsp; &nbsp; &nbs...
#190 MCQ
What is printed by the following ANSI C program? #include&lt;stdio.h&gt; int main(int argc, char *argv[]) { &nbsp; &nbsp; int a[3][3][3] = &nbsp; &nbsp; {{...
#311 MCQ

Related Topics

GATE 2025 Computer Science CSE Set 2 Question 62 C Programming Operating Systems fork() execlp() wait() Process Creation System Calls Process Management Child Process Parent Process UNIX System Calls NAT Numerical Answer Type 2 Marks

Unique Visitor Count

Total Unique Visitors

Loading......