• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Functions

Question 41

Assuming int size is 4 bytes, what is going to happen when we compile and run the following program? 
 

C
#include “stdio.h”
int main()
{
  printf(GeeksQuiz\\n);
  main();
  return 0;
}
  • We can’t use main() inside main() and compiler will catch it by showing compiler error.
     

  • GeeksQuiz would be printed in 2147483647 times i.e. (2 to the power 31) - 1.
     

  • It’ll print GeeksQuiz infinite times i.e. the program will continue to run forever until it’s terminated by other means such as CTRL+C or CTRL+Z etc.
     

  • GeeksQuiz would be printed only once. Because when main() is used inside main(), it’s ignored by compiler at run time. This is to make sure that main() is called only once.
     

  • GeeksQuiz would be printed until stack overflow happens for this program.
     

There are 41 questions to complete.

Last Updated :
Take a part in the ongoing discussion