Second smallest number in the list
Not what you're looking for?
Write a Ruby program with the following specification:
Input: A list of numbers from the keyboard.
Output: The second smallest number in the list, along with its position in the list, with 1 being the position of the first number.
Purchase this Solution
Solution Summary
Ruby program in the solution assumes that input contains at least two numbers. If you give less than two numbers as input, it will not output anything.
Solution Preview
Please save the following program in a file, say, number.rb . If you give less than 2 numbers as input, it won't output anything.
------------- Program text ------------
#!/usr/bin/ruby
numberList = Hash.new
#
# Read a list of numbers from the keyboard.
#
puts "Enter numbers one per line."
count = 1
$stdin.each_line ...
Purchase this Solution
Free BrainMass Quizzes
C++ Operators
This quiz tests a student's knowledge about C++ operators.
Word 2010: Table of Contents
Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.
Javscript Basics
Quiz on basics of javascript programming language.
Basic UNIX commands
Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.
C# variables and classes
This quiz contains questions about C# classes and variables.