Write a program which employs Recursion



Write a program which employs Recursion..

Answer / Mohit Singh

Here's a simple recursive function example in C++ that calculates the factorial of a given number:n```nvoid factorial(int n, long long result = 1) {n if (n > 1) {n factorial(n - 1, result *= n);n }n cout << result;n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Which operator cannot overload?

1 Answers  


What c++ library is string in?

1 Answers  


Define basic type of variable used for a different condition in C++?

1 Answers  


What is a hash function c++?

1 Answers  


What is the difference between *p++ and (*p)++ ?

1 Answers  


Is c# written in c++?

1 Answers  


What are the advantages of using friend classes?

1 Answers  


What is 'Copy Constructor' and when it is called?

1 Answers  


Live example for static function?

1 Answers   Infosys,


What is else syntax in c++?

1 Answers  


Do you need a main function in c++?

1 Answers  


Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).

1 Answers  


Categories