Program of a factorial using recursive function in Data Structures (C plus plus)

Program of a factorial using a recursive function in Data Structures (C plus plus)

In this tutorial, we will learn about the Program of a factorial using a recursive function in Data Structures (C plus plus).

#include<iostream>

using namespace std;

main()
{
	long factorial (int), z;
	cout<<"Please enter any integer value:"<<endl;
	cin>>z;
	cout<<"The factorial of "<<z<<"="<<factorial(z);
}	


long factorial(int k)
{
	if(k==1)
	return 1;
	else
	return k*factorial(k-1);
}

Output:

Program of a factorial using recursive function through Data Structures (C plus plus)
Program of a factorial using a recursive function in Data Structures (C plus plus)

 

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.