The problem is this scanf call and the use of the %c format specifier. Prior to this you entered the number of years (followed by the enter key). The years were stored into your variable ys but the newline character was left in the input buffer/stream. Coupled with the %c format specifier, the scanf call above read and stored the newline character (which was the first one available from the buffer as it was left over from the previous input operation) into ch instead of the f/p you were expecting.

There are several ways to deal with this, probably the easiest is to put a space in front of the %c format specifier which will instruct the scanf call to disregard leading whitespace (i.e. newlines, etc...).

"Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
-Christopher Hitchens