Um...what did you expect that to do?
scanf("%c", &(char){ch} );
if (ch == 'y' || ch == 'Y')
continue;
That doesn't "declare" anything - and if it did (which it can't, it's not allowed by the C syntax), it wouldn't logically be available outside the call to scanf. So the subsequent line wouldn't be able to access it anyway.
And the semicolon at the end of the
for
loop doesn't help either...
Try this instead:
int main ()
{
int c,n,fact = 1;
char ch[100];
printf("Enter a number to calculate it's factorial\n");
...
scanf("%c", ch );
if (ch[0] == 'y' || ch[0] == 'Y')
{
continue;
}
else
{
break;
}
return(0);
}
Except you'll need a loop round most of it for the
continue
/
break
logic to work!