#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
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:
Post a Comment