Why doesn’t control enter the repeat() function? [closed]

Why do Control don’t enter repeat() function?

Because main() does not call it.

The repeat() function is defined inside main(). Which is non standard. Moving it out makes things clearer:

#include <stdio.h>

int num ;

int repeat()
{  
    scanf("%d", &num);
    if(num != 42)
    {
        printf("\n%d", num);

        repeat();
    }
    else
    {
        return num ;
    }

    getch();
}

int main() {
    return 0;
}

From the above it is obvious that main() in fact does nothing.

Leave a Comment