import java.util.Scanner;
import java.util.*;
public class Example {
public static void main(String args[])
{
int max=Integer.MIN_VALUE;
int min=Integer.MAX_VALUE;
System.out.println("Enter the length of elements: ");
Scanner sc = new Scanner(System.in);
int[] arr = new int[sc.nextInt()];
System.out.println("Enter the elements: ");
for(int i=0;i
{
int next = sc.nextInt();
arr[i] = next;
}
for(int j=0;j
{
if(arr[j]>max)
max = arr[j];
else if(arr[j]
min = arr[j];
}
System.out.println("Largest Value in array: " + max);
System.out.println("Smallest Value in array: " + min);
}
}
output is : -
Enter the length of elements:
4
Enter the elements:
21
34
6
98
Largest Value in array: 98
Smallest Value in array: 6
import java.util.*;
public class Example {
public static void main(String args[])
{
int max=Integer.MIN_VALUE;
int min=Integer.MAX_VALUE;
System.out.println("Enter the length of elements: ");
Scanner sc = new Scanner(System.in);
int[] arr = new int[sc.nextInt()];
System.out.println("Enter the elements: ");
for(int i=0;i
{
int next = sc.nextInt();
arr[i] = next;
}
for(int j=0;j
{
if(arr[j]>max)
max = arr[j];
else if(arr[j]
min = arr[j];
}
System.out.println("Largest Value in array: " + max);
System.out.println("Smallest Value in array: " + min);
}
}
output is : -
Enter the length of elements:
4
Enter the elements:
21
34
6
98
Largest Value in array: 98
Smallest Value in array: 6
No comments:
Post a Comment