🎴 Flashcard Mode

Programming in C

Card1 / 5
Mastered0
Review0
QuestionClick to flip

What will be the output of the given program?

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

AnswerClick to flip back
A
Error: Stack overflow
💡 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.

Change Mode