WAP to using Scanner class to input 10 integers in a single dimensional arrays X[ ]. Find and print the smallest number from them.
Answers
Answered by
0
Answer:
import java.util.*;
public class Main
{
public static void main(String[] args) {
int[] arr = new int[10];
Scanner sc = new Scanner(System.in);
System.out.println("Enter all 10 numbers:");
for(int i = 0; i < 10; i++){
arr[i] = sc.nextInt();
}
Arrays.sort(arr);
System.out.println("The smallest number is " + arr[0]);
}
}
Explanation:
Similar questions