It is certainly a learning experience to have a go at using Horner's Method to parse integers, but you might want to look at Serial.parseInt().
Also note that the compiler should have given you a warning message about the getanswer() function. Something like "not all code paths return a value". The function should always return a value to the caller. In this case it should have a return statement when Serial.available() is 0 and when ch is not equal to 10.