Recap - Dynamic Input
Part of the Fundamentals section of Coddy's Ruby journey — lesson 47 of 88.
Challenge
EasyRead a count n from input, followed by n integers. Find and print the largest number among the inputs.
The first input is the count of numbers to follow. Then read that many numbers using a loop and track the maximum value.
For example, if the inputs are:
4
7
2
9
5The output should be:
9If the inputs are:
3
15
8
22The output should be:
22Try it yourself
# Read the count of numbers
n = gets.to_i
# TODO: Write your code below
# Read n numbers and find the largest one
# Output the result
puts maxAll lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 42Variables and Data Types
Numbers and VariablesString Data TypeBoolean Data TypeSymbol Data TypeChecking Data TypesNaming ConventionsRecap - Variable Creation8Loops
For Loop with RangesWhile LoopBreakNextRecap - FactorialTimes LoopUntil LoopNested LoopsRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators6Basic IO
Output with putsOutput with print and pOutput With VariablesInput with getsChomp MethodType ConversionRecap - Age CalculatorRecap - True or False