Q:

Write a Ruby program to print even numbers from 1 to 10

0

 Write a Ruby program to print even numbers from 1 to 10.

All Answers

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

puts "Even numbers between 2 to 10: "
2.step 10, 2 do |x|
      puts "#{x}"
 end
Output:
Even numbers between 2 to 10: 
2
4
6
8
10

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