Regarding calling of function

Can the main function be called under another function?

Hey @Nitin-Bhattacharyya-2319140631658033
Yes it can be called by other functions but I never tried that, also its not a good practice as it flow of control is not clear in those cases.

Here check this simple recursion of main :slight_smile:

#include <iostream>
using namespace std;
int i=5;
int main() {
    if(i==0)return 0;
    cout<<"Hello World!\n";
    i--;
    main();
}

thanks for clearing the doubt

1 Like