+ 2
Could anyone tell me what is the meaning of a (Recursive function) used in c++ ??
2 Réponses
+ 2
When you're calling the same function inside the function, using given arguments to evaluate what to do.
//call
countToTen(0);
.
.
.
// definition
void countToTen(int currentCount){
if (currentCount <= 10) {
std::cout << currentCount << " ";
countToTen(currentCount++)}
}
It keeps printing currentCount and calling itself with an increment and stops when currCount is no longer <=10.
Output should be 0 1 2 3 4 5 6 7 8 9 10
+ 2
@Echo thank you alot