galinyotsev123

ProgBasics06For-Loop-P05minNumber

Jan 5th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class P05minNumber {
  3. public static void main (String[]args) {
  4. Scanner scanner = new Scanner(System.in);
  5. System.out.print("n = ");
  6. int n = scanner.nextInt();
  7.  
  8. System.out.println("Enter the numbers: ");
  9. int min = Integer.MAX_VALUE;
  10.  
  11. for (int i = 1; i <= n; i++) {
  12. int num = scanner.nextInt();
  13.  
  14. if (num <min) {
  15. min = num;
  16. }
  17. }
  18. System.out.println("min = " + min);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment