Make a function that will add 36 to the passed value if that
Make a function that will add 36 to the passed value if that value is EVEN or subtract 35 if the input is ODD.
Solution
function y=subtractifodd(x)
if rem(x,2)==0%finding remainder of(x/2) if it is 0 then we add 36 to it
y=x+36;
else%if it is not zero we subtract 35 from it
y=x-35;
end
end
Output:
>> subtractifodd(56)
ans =
92
>> subtractifodd(57)
ans =
22
