Mushfiq Mammadov wrote:It is confusing for me, parameter type is int but we pass char type value as parameter?! When we pass int, return value always be “-1”. What happens?
No, it doesn't return always
-1. Let's have a look at this example:
Output:
1 -1 7
If you don't know what's happening behind the scenes, it looks like magic or even voodoo

If you know what's happening, it's very easy (as always). Now let's look at this code snippet:
Magic isn't it?

What's really happening is very well explained in
this (and following) posts. (Disclaimer: these posts are mine so probably a little biased

)