Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

sum of nos

a=[0,1,2,3,4,5,6,7,8,9,10]
puts "enter a number in the range 1-10"
num=8
sum=0
b=[]
a.each do |i|
    a.each do |j|
        sum=i+j
        if sum==num
        b << i
        b << j
        print b
        b.clear
    end
    end
end

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.