Your main doesn't have a closing brace. You also can't have nested functions, so the use of even and odd in determine has to be done differently.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Im a newbie to C programming...
Then I'll adjust my next answer accordingly, because it's not exactly a trivial problem.
>when you enter a number the console goes away..
You're using getchar to pause the program it seems, but because there's still a newline left in the stream, getchar reads it immediately and doesn't block. You can add a second getchar:
int main(void)
{
int num1, even, odd;
printf("Enter a number: ");
scanf("%d", &num1);
printf("The number is: %d", determine(num1));
scanf("%d", &num1);
getchar();
getchar();
return 0;
}
And that will probably work, or you can loop until you find a newline, which is more likely to work most of the time:
int main(void)
{
int num1, even, odd;
printf("Enter a number: ");
scanf("%d", &num1);
printf("The number is: %d", determine(num1));
scanf("%d", &num1);
while ( getchar() != '\n' )
;
getchar();
return 0;
}
Notice that I changed your void main to int main and returned a value. void main is wrong, don't do it.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401