## 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).

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#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:**

Latest posts by Prof. Fazal Rehman Shamil (see all)