You should never call main
from within your program. If you need to run it more then once use a while
loop inside it.
Your execution stops because by default stdin in a terminal is line buffered. Also you are not using the return value from getch
.
int main()
{
int n,op;
char c;
do {
printf("Enter n value\n");
scanf("%d",&n);
op=f(n);
printf("%d",op);
printf("want to enter another value: (y / n)?\n");
scanf("%c",&c);
} while (c == 'y')
return 0;
}