Write a Ruby program to check two integer values and return true if they are both in the range 10..20 inclusive,
- برمجة
- برمجة روبي
- 2021-08-30
- mhanasmh00489829403
الأجوبة
def test_int(a, b)
return (((a >= 10 && a <= 20) && (b >= 10 && b <= 20)) ||
((a >= 20 && a <= 30) && (b >= 20 && b <= 30)));
end
print test_int(10, 15),"\n"
print test_int(6, 9),"\n"
print test_int(22, 30),"\n"
print test_int(45, 55)
Output:
true false true false
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال