C Programming - Functions - Discussion
Discussion Forum : Functions - General Questions (Q.No. 3)
3.
How many times the program will print "IndiaBIX" ?
#include<stdio.h>
int main()
{
printf("IndiaBIX");
main();
return 0;
}
Answer: Option
Explanation:
A call stack or function stack is used for several related purposes, but the main reason for having one is to keep track of the point to which each active subroutine should return control when it finishes executing.
A stack overflow occurs when too much memory is used on the call stack.
Here function main() is called repeatedly and its return address is stored in the stack. After stack memory is full. It shows stack overflow error.
Discussion:
31 comments Page 4 of 4.
Sanket said:
1 decade ago
I tried this program on Turbo C++ 4.5 compiler and it gives me error "Cannot call 'main' from within the program in function main()
Also where we used stack here??
Does stack refers to 'Main Memory'?
Also where we used stack here??
Does stack refers to 'Main Memory'?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers