Scala Programming: Find the maximum and minimum value of an array of integers
Write a Scala program to find the maximum and minimum value of an array of integers.
Sample Solution:
Scala Code:
Sample Output:
Original Array elements: 1, 2, 3, 4, 5, 7, 9, 11, 14, 12, 16, Maximum - Minimum value of the said array: (1,16) Original Array elements: -111, -124, Maximum - Minimum value of the said array: (-124,-111) Original Array elements: 10, Maximum - Minimum value of the said array: (10,10)
Scala Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Scala program to rotate one element left of an given array (length 1 or more) of integers.
Next: Write a Scala program to calculate the sum of the last 3 elements of an array of integers. If the array length is less than 3 then return the sum of the array. Return 0 if the array is empty.
What is the difficulty level of this exercise?
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics