Q:

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

0

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

All Answers

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

puts "Odd numbers between 9 to 1: "
9.step 1, -2 do |x|
      puts "#{x}"
 end
Output:
Odd numbers between 9 to 1: 
9
7
5
3
1

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