Computer Science, asked by sarthaksingh62, 10 months ago

WRITE A PROGRAM IN JAVA TO ENTER TEN NUMBERS AND PRINT THE HIGHEST NUMBER USING FOR LOOP.

PLEASE HELP​

Answers

Answered by tinalalwani
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