+ 5
Recursions in C++ ??
Explain with example..
7 odpowiedzi
+ 6
+ 6
Shehroz Irfan Here is an example
#include <iostream>
using namespace std;
size_t Factorial(size_t num);
int main()
{
size_t num = 0;
cin >> num;
cout << "Entered number: " << num << endl;
size_t fact = Factorial(num);
cout << "Factorial of " << num << " is: " << fact << endl;
return 0;
}
size_t Factorial(size_t num)
{
if(num == 0)
return 1;
else
return num * Factorial(num - 1);
}
+ 6
nAutAxH AhmAd
👍👍👍
+ 5
D_Stark
example?
+ 4
its when a method calls its self repeatedly until it solves given task
+ 4
+ 1
Definition of the recursion: It is the same as the recursion, see the definition of the recursion until it is clear.