Answer to Question #276091 in Java | JSP | JSF for Candy

Question #276091

1. Write pseudo code that prints the smallest value among a list of numbers. (10 marks) 


1
Expert's answer
2021-12-06T05:26:45-0500


package list;


import java.util.Scanner;


public class List {


   
    public static void main(String[] args) {
        Scanner scan  = new Scanner(System.in);
        System.out.println("Enter the  number of elements of the list");
        int n = scan.nextInt();
        System.out.printf("Enter %d of the list\n", n);
        int  [] arr = new int [n];
        for(int i=0; i<n; i++){
            arr[i] = scan.nextInt();
        }
        
        int min = arr[0];
        for(int i=0; i<n; i++){
            if(arr[i]<min){
                min = arr[i];
            }
        }
        System.out.printf("Smallest value in the list is %d\n", min);
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS