From 7cc7f2b9e141b3730eb30794e2288da17b5ee830 Mon Sep 17 00:00:00 2001 From: Krishnanand Bhat <54655236+Krxshna@users.noreply.github.com> Date: Sat, 8 Oct 2022 23:04:58 +0530 Subject: [PATCH] Added program to find largest and smallest element in an array --- Java/largestAndSmallest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Java/largestAndSmallest.java diff --git a/Java/largestAndSmallest.java b/Java/largestAndSmallest.java new file mode 100644 index 0000000..19731c8 --- /dev/null +++ b/Java/largestAndSmallest.java @@ -0,0 +1,23 @@ +import java.util.*; + +public class Main +{ + public static void main(String[] args) { + Scanner s=new Scanner(System.in); + int n=s.nextInt(); + int a[]=new int[n]; + for(int i=0;imax){ + max=a[i]; + } + } + System.out.println("The min is:"+ min +" and max is:"+ max); + } +}