Pages

💡 Now You Can Get your Assignments Sollution here... .💡 100% plagiarism Free Service...💡 Responsibility, punctuality and on-time delivery... 💡 Furnishing you with experts... 💡 experienced in your subject 100% privacy... 💡 helping you with the highest efficiency , professionalism Affordable and budget-friendly costs that do not make a hole in your wallet

C++ Code to find Factorial using Recurtion

#include<iostream>
using namespace std;

void Fac(int n, int &ans) //& use to get address
{
ans*=n; // is ans=ans*n;
if(n>1)
Fac(n-1, ans); // 'ans' passed by reference
}
int main()
{
int numb = 0;
int ans = 1;
cout<<"Enter number: ";
cin>>numb; //Getting number
Fac(numb, ans);
cout<<ans<<"\n";
cout<<endl;
return 0;
}

// For any query type it in comment or chat with any online Admin

No comments: