Thursday, January 6, 2022

Factorial a Number Using Recursion in C++

 A program that will demonstrate how to use recursion to solve the factorial value of the given number using C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Program Listing

#include <iostream> int factorial(int n); int main() { int num_val=0; std::cout << "\n\n"; std::cout << "\tFactorial a Number Using Recursion in C++"; std::cout << "\n\n"; std::cout << "\tGive a Number : "; std::cin >> num_val; std::cout << "\n\n"; std::cout << "\tFactorial of " << num_val << " = " << factorial(num_val); std::cout << "\n\n"; std::cout << "\tEnd of Program"; std::cout << "\n\n"; return 0; } int factorial(int n) { if(n > 1) return n * factorial(n - 1); else return 1; }

No comments:

Post a Comment