Advantages:
Through Recursion one can Solve problems in easy way while
its iterative solution is very big and complex.
Ex : tower of Hanoi
You reduce size of the code when you use recursive call.
Disadvantages :
Recursive solution is always logical and it is very
difficult to trace.(debug and understand)
Before each recursive calls current values of the varibles
in the function is stored in the PCB, ie process control
block and this PCB is pushed in the OS Stack.
So sometimes alot of free memory is require for recursive
solutions.
Remember : whatever could be done through recursion could be
done through iterative way but reverse is not true.
If you're asking if the c preprocessor supports recursive macros, the answer is no. The preprocessor is single-pass and since the "function" must be defined before it can be referenced, it can not be recursive.
Functions in C language may call themselves (ie can be recursive) without restrictions.
A self-referential function in C++, or in any other supporting language, is a recursive function.
Write a merits and demerits of using function in program
The inline attribute is a C++ attribute, not a C attribute. Inline specifies that the function is to be expanded in place at the point of call instead of being called as a function. This means there will be one copy of the function for each call. This costs executable code, but can save execution time because the call setup and return time is avoided. Some functions cannot be inlined, and inline is really only a hint to the compiler. As far as recursive inlined functions, that depends on the implementation. The Microsoft implementation will not inline recursive functions unless they have a #pragma inline depth(n) line that specifies the maximum recusion depth the function will have. Consult your specific compiler documentation for the inline attribute for your specific implementation details.
I will explain in the easiest way the difference between the function and recursive function in C language. Simple Answer is argument of the function is differ but in the recursive function it is same:) Explanation: Function int function(int,int)// function declaration main() { int n; ...... ...... n=function(a,b); } int function(int c,int d) { ...... ...... ...... } recursive Function: int recursive(int,int)// recursive Function declaration main() { int n; ..... ..... ..... ..... n=recursive(a,b); } int recursive(int a,int b) { ..... .... .... .... } Carefully see, In the recursive Function the function arguments are same.
Yes
non recursive function is excuted faster than recrussive
If you're asking if the c preprocessor supports recursive macros, the answer is no. The preprocessor is single-pass and since the "function" must be defined before it can be referenced, it can not be recursive.
* Debugging is easier * It is easier to understand the logic involved in the program * Testing is easier * Recursive call is possible * Irrelevant details in the user point of view are hidden in functions * Functions are helpful in generalizing the program
biggest3 (a,b,c) = biggest2 (a, biggest2 (b,c))
Functions in C language may call themselves (ie can be recursive) without restrictions.
i love u darling
A self-referential function in C++, or in any other supporting language, is a recursive function.
The main advantage of recursive functions is that each call to the function maintains the state of the local variables from the previous call, which can then be re-used as the function calls begin to "unwind". However, function calls are expensive in terms of both performance and memory consumption, so it's important to recognise when recursion is required and when it is not. If the state prior to each call is not required when the call returns, iteration would be a far better option.
Some function are not using in c
Write a merits and demerits of using function in program