sum()
{
return $(($1+$2))
}
read a b
sum $a $b
echo $?
when we pass the value for a=255 and for b=36 the ans will be 35 why?
sum()
{
return $(($1+$2))
}
read a b
sum $a $b
echo $?
when we pass the value for a=255 and for b=36 the ans will be 35 why?
As everybody pointed out, shell function cannot return a value greater that 255.
The common way to get values out of functions is to store them in a variable like so:
you are asking the shell to return the value.
The return value cannot be anything more than 255.
so when you add a=255 and b=36
but since it can only return a value from 0-255.
you subtract
hence your return value of 35.