Recursive Function Assignment Help

Assignment Help: >> Functions, Arguments and Overloading - Recursive Function

Recursive function

A Recursive function is that which calls itself directly or indirectly again and again is known as the recursive function. A Recursive functions are very useful although constructing the data structures such as linked lists, double linked lists or trees.  There is a distinct difference among normal and recursive functions. A normal function will be invoked through the main function whenever the function name is used.  The recursive function will be invoked through itself directly or indirectly as long as the given condition is satisfied.

Instance:

# include<iostream.h>

{

void main(void)

{

void f1 ( ); // function declaration

f1 ( ); // function calling

}

void f1( ) // function definition

{

f1 ( ); //function calls recursively

}

Sample program

# include<iostream.h>

void main( void)

{

int sum(int);

int n, temp;

cout<<"Enter any number"<< endl;

cin>>n;

temp = sum(n);

cout<<"value = "<<n<<"and its sum ="<< temp;

}

int sum ( int n)

{

int sum (int); // local function

int value = 0;

if (n= = 0)

return(value);

else

value = n+sum(n-1);

return (value);

}

output of the program is

Enter an integer number

4

value = 4 and its sum = 10

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd