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 2 of 4.
Benito said:
8 years ago
Thank you all for the given explanation.
Shiny vn said:
1 decade ago
Its a C program you may try by using some other or can try with terminals.
Within said:
1 decade ago
Explain the problem once again?
Kavin said:
1 decade ago
int main()
{
printf("hello");
main();
return 0;
}
It will show the abnormal program termination message in turbo C++ 4.0 compiler.
{
printf("hello");
main();
return 0;
}
It will show the abnormal program termination message in turbo C++ 4.0 compiler.
Vin... said:
1 decade ago
@Kavitha: Your program has syntax errors:
1) Complete the double Quote.
2) Use \n for new line you used /n.
Please make it correct or run this program on Dec C compiler.
OUTPUT is : Return value of f(11100) is: 0.
void main()
{
printf("Return value of f(%d) is %d:\n",11100,f(11100));
}
int f(int n)
{
if(n<=0)
return 0;
else
1+f(n/10);
}
1) Complete the double Quote.
2) Use \n for new line you used /n.
Please make it correct or run this program on Dec C compiler.
OUTPUT is : Return value of f(11100) is: 0.
void main()
{
printf("Return value of f(%d) is %d:\n",11100,f(11100));
}
int f(int n)
{
if(n<=0)
return 0;
else
1+f(n/10);
}
Kavitha said:
1 decade ago
Can any one help me out in solving the following problem?
void main()
{
printf("Return value of f(%d) is %d/n,11100,f(11100));
}
int f(int n)
{
if(n<=0)
return 0;
else
1+f(n/10);
}
void main()
{
printf("Return value of f(%d) is %d/n,11100,f(11100));
}
int f(int n)
{
if(n<=0)
return 0;
else
1+f(n/10);
}
Sandy said:
1 decade ago
Can anybody tell how much amount of stack memory is allocated and upon which this depends?
Ram said:
1 decade ago
We can call main function with in a main function and in this we have " ; " how?
Srini said:
1 decade ago
@Kuldeep chaudhary.
#include< >- It means that the pre-processor pre-compiles the system files and extracts the definitions from that file.
#include" "- Same process takes place and the only difference is that, it considers the name, which is defined inside the "" as an user defined file.
#include< >- It means that the pre-processor pre-compiles the system files and extracts the definitions from that file.
#include" "- Same process takes place and the only difference is that, it considers the name, which is defined inside the "" as an user defined file.
Pari said:
1 decade ago
How can main can call main function?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers