Recursions in C++ ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Recursions in C++ ??

Explain with example..

4th Sep 2018, 6:38 PM
Shehroz Irfan
Shehroz Irfan - avatar
7 Answers
4th Sep 2018, 6:38 PM
Shehroz Irfan
Shehroz Irfan - avatar
+ 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); }
4th Sep 2018, 7:19 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 6
nAutAxH AhmAd 👍👍👍
5th Sep 2018, 9:40 AM
Shehroz Irfan
Shehroz Irfan - avatar
+ 5
D_Stark example?
4th Sep 2018, 6:54 PM
Shehroz Irfan
Shehroz Irfan - avatar
+ 4
its when a method calls its self repeatedly until it solves given task
4th Sep 2018, 6:41 PM
D_Stark
D_Stark - avatar
5th Sep 2018, 9:40 AM
Shehroz Irfan
Shehroz Irfan - avatar
+ 1
Definition of the recursion: It is the same as the recursion, see the definition of the recursion until it is clear.
4th Sep 2018, 8:02 PM
Sergey Ushakov
Sergey Ushakov - avatar