Write a Ruby program to compute the absolute difference between n and 33 and return double the absolute difference if n is over 33.
Ruby Code:
def diff_33(n) n > 33 ? ((n-33)*2).abs : (n-33).abs end print diff_33(47),"\n" print diff_33(17)
Output:
28 16
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Ruby Code:
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer