The problem is that you don't do any error checking:
C library function - scanf()[
^] returns a negative number if a "bad value" is entered and you do not check for this, you just assume that the value in
input
is always correct and valid.
Modify your
display
function to check the response, and repeat until the user types something right. And change its name! It doesn't "display" it prompts for input and gets a value from the user.
But that's not your only problem: because you use
scanf
with a numeric code - "%d" - it will never return '\n', so that won;t work too well either.
What I'd suggest is that you use
scanf
to read a line of characters from the user, and then check that for "empty" - if it's empty, then the user pressed ENTER without a number and you are done. If it isn't, then use
C library function - atoi()[
^] to try and convert it to an integer. You can then throw out your A-Z checking and just get on with the factorial.
Do be aware that factorials get very large, very quickly: they will exceed an 32 bit integer long before n reaches 33!