An illustrative problem lies at the beginning of the if-else sequence:
Code:
if(isdigit(answer))
The isdigit() function is meant to take a single
char variable--not an int. The purpose of the isdigit() function is to verify that one or more characters in a string contain a digit (i.e. 0-9).
For instance, take the following code:
Code:
#include <stdio.h>
int main( int argc, char *argv() )
{
char charNumber='9';
int intNumber=9;
if( charNumber == intNumber )
printf( "The values match!\n" );
else
printf( "The values ARE NOT EQUAL!\n" );
return 0;
}
If you run the above code, you will get "The values ARE NOT EQUAL!" for output. The char representation of 9 is a numeric value from the ASCII table. The int representation of 9 is the binary value of 9.
All of this to say two things:
1. It appears that the program is intended to do some user-input verification.
2. Assuming #1 is true, the "Please select a number." should be moved out of the interior if-else clause to serve as the else for the isdigit()/input verification code.