How to return variable in function

In reply to jishan_bukhari:

In the future, please use code tags to make your question more readable. I have added them for you.

Your function declaration has no return type. Per the LRM, it should be:

function < return_type > < function_name >(< arguments >);

Since you have no return type specified, it defaults to a single bit, hence the ‘1’ being returned.