#define f(x) (x*(x+1)*(2*x+1))/6 void terminate(); main() { int n,op; char c; 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); // execution stops here itself without taking input. getch(); if(c=='y') main(); else terminate(); getch(); } void terminate() { exit(1); } In the program above , I want to take input from the user until he enters an n value. For this I'm trying to call main() function repeatedly . If it is legal in C , I want to know why the program terminates at the scanf("%c",&c) as shown in commented line. Someone , please help.
int main(void)at least. And assumingterminate()is not meant to take any parameters, it should bevoid terminate(void).