This is an example or recursion in which there is a function inside a function here are the codes and the ouput:
Output:
Codes:#include<.....>
#include<......>
#include<......>
using namespace std;
int factorial(int num)
{
if(num==0)
return 1;
else
return num*factorial(num-1);
}
int main()
{int z;int num;
menu:system("cls");
cout<<"Enter number: ";
cin>>num;
z=factorial(num);
cout<<<"";
cout<<"\n\n";
system("pause");
system("cls");
goto menu;
getch();
}
Powered by Blogger.
Post a Comment