mirror of
https://github.com/TheAlgorithms/Ruby
synced 2025-01-13 08:01:03 +01:00
add output for add algo
This commit is contained in:
parent
fbe6e9851d
commit
256f376574
1 changed files with 19 additions and 5 deletions
24
maths/add.rb
24
maths/add.rb
|
@ -10,11 +10,25 @@ def add(*array)
|
|||
puts "Error: Please provide number only!"
|
||||
end
|
||||
|
||||
#
|
||||
# Valid inputs
|
||||
add(1)
|
||||
add(2, 5, -4)
|
||||
add(25, 45)
|
||||
#
|
||||
|
||||
puts add(1)
|
||||
# The sum of following elements [1] is 1
|
||||
|
||||
puts add(2, 5, -4)
|
||||
# The sum of following elements [2, 5, -4] is 3
|
||||
|
||||
puts add(25, 45)
|
||||
# The sum of following elements [25, 45] is 70
|
||||
|
||||
#
|
||||
# Invalid inputs
|
||||
add("1", 2, 3)
|
||||
add("a", 1)
|
||||
#
|
||||
|
||||
puts add("1", 2, 3)
|
||||
# Error: Please provide number only!
|
||||
|
||||
puts add("a", 1)
|
||||
# Error: Please provide number only!
|
||||
|
|
Loading…
Reference in a new issue