if so then why is the return type named int instead of char?
For the same reason the parameter type is int instead of char, and why getchar returns int: to support EOF. If EOF were representable by char, how would you know the difference between EOF and a legitimate character with the same value?
Suppose you created a function that takes integer type value, converting this integer value into its corresponding ascii value and displays it(using any other function/code which is within your created function).
Now whatever the function returns, it has already displayed the character before returning any values.
Then the returned value may be used to check if the putchar() worked or not.Which is why EOF is returned when writing is successful and an integer otherwise.