Pages

Thursday, May 22, 2025

What is recursion? in C++

 Recursion:

A function that repeatedly calls itself.


CODE:

#include<iostream>

using namespace std;

// recursive function -> recursion..

void func() {
cout << "function call...work\n";

func(); // calls itself 

}


int main() {
func();

return 0;

}


OUTPUT:-

function call..work


function call..work


function call..work


function call..work


function call..work

...

.

..

infinite times, until a base case is declared(Smallest problem, where solution is known)..

No comments:

Post a Comment

how to become red on codeforces by Errichto Algorithms | explained simply in a blog

 Yes. I found an available transcript of the video and summarized it simply. The video is “How To Become Red Coder? (codeforces.com)” by Err...