Multiple choice

What will be the output of the given program?

int main()
{
 printf(Hello World\\n);
 main();
 return 0;
}

  1. Infinite loop

  2. Hello World is printed 65535 times

  3. Error: Calling main() function is not allowed

  4. Error: Stack overflow

  5. None of these

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The program will run for some time, and after that it will give an error. The reason is :-A stack(call stack) is used to store information about the active subroutines of a computer program. So whenever control transfer from one function(subroutine) to another function, return address and other parameter are stored on stack.In above program main is calling itself repeatedly, it creates an infinite loop. Each call pushes return address and other parameters to call stack and it continues till stack is full. When stack is full it terminates with error : Segmentation fault (core dumped).So this is the correct answer.