//Write a Java program to find the maximum element in array

 


import java.util.Scanner;
public class CDM_P6 {
public static void main(String[] args) {
int []array = {56,89,67,45,23,78};
int max =0;
for(int element:array){
if(element>max){
max = element
;
}
}
System.
out.println("The value of the maximum element in this array is: " +max);
}
}

//output
The value of the maximum element in this array is: 89 Process finished with exit code 0



Post a Comment

0 Comments