In the case of the implicit recursion, the issue of an infinite function call may occur. Here is a case where implicit recursion can cause the problem:
C++
#include <iostream>
using namespace std;
void func2();
void func1();
void func1() {
cout << "This is the first function" << endl;
func2();
}
void func2() {
cout << "This is the second function" << endl;
func1();
}
int main() {
func1();
return 0;
}
|
Java
import java.io.*;
class GFG {
static void func1(){
System.out.println( "This is the first function" );
func2();
}
static void func2(){
System.out.println( "This is the second function" );
func1();
}
public static void main (String[] args) {
func1();
}
}
|
Python3
def func1():
print ( "This is the first function" )
func2()
def func2():
print ( "This is the second function" )
func1()
func1()
|
C#
using System;
public class GFG {
static void func1()
{
Console.WriteLine( "This is the first function" );
func2();
}
static void func2()
{
Console.WriteLine( "This is the second function" );
func1();
}
static public void Main()
{
func1();
}
}
|
Javascript
function func2() {
console.log( "This is the second function" );
func1();
}
function func1() {
console.log( "This is the first function" );
func2();
}
func1();
|
This is the first function
This is the second function
This is the first function
This is the second function
...
...
In this example, the func1() function calls func2(), which then calls func1() once again.