Q:

Write a Ruby program to check two given integers and return the larger value

0

Write a Ruby program to check two given integers and return the larger value. However if the two values have the same remainder when divided by 5 then return the smaller value and if the two values are the same, return 0.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_num(a, b, c)
    if(b > a)
		temp = a
		a = b
		b = temp
    end

    if(c > b)
		temp = b
		b =c
		c = temp
    end

	if(b > a)
		temp = a
		a = b
		b = temp
	end
  return(a - b == b - c)
end
print check_num(5, 10, 15),"\n"
print check_num(2, 3, 11),"\n"
Output:
true
false

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now