1.

Explain recursive functions with the help of a suitable example.

Answer»

A function calls itself is called recursive function. 

#include <iostream>

using namespace std; 

void convert(int n) 

if(n>1) 

convert(n/2); 

cout<<n % 2; 

int main() 

convert(7); 

Here the function convert is a recursive function, that means it calls itself and output of the above program is 111.



Discussion

No Comment Found

Related InterviewSolutions