WRITE A PROGRAM IN JAVA TO ENTER TEN NUMBERS AND PRINT THE HIGHEST NUMBER USING FOR LOOP.
PLEASE HELP
Answers
Answered by
0
Explanation:
Input : arr[] = {10, 20, 4}
Output : 20
Input : arr[] = {20, 10, 20, 4, 100}
Output : 100
Method 1: Iterative Way
// Java Program to find maximum in arr[]
class Test
{
static int arr[] = {10, 324, 45, 90, 9808};
// Method to find maximum in arr[]
static int largest()
{
int i;
// Initialize maximum element
int max = arr[0];
// Traverse array elements from second and
// compare every element with current max
for (i = 1; i < arr.length; i++)
if (arr[i] > max)
max = arr[i];
Similar questions
Math,
5 months ago
Environmental Sciences,
5 months ago
Science,
5 months ago
Social Sciences,
10 months ago
Science,
10 months ago
Math,
1 year ago
Chemistry,
1 year ago