Code:
import java.util.Random;
import java.util.Scanner;
public class Minimum_Using_Sequential
{
static int N = 20;
static int []sequence = new int[N];
public static int minSequential()
{
int min = sequence[0];
for(int i=0; i
if(min > sequence[i])
min = sequence[i];
return min;
}
public static void main(String args[])
{
Random random = new Random();
for(int i=0; i
sequence[i] = Math.abs(random.nextInt(100));
System.out.println("The sequence is :");
for(int i=0; i
System.out.print(sequence[i] + " ");
Scanner sc = new Scanner(System.in);
System.out.println("\nThe minimum element in the sequence is : " + minSequential());
sc.close();
}
}
Output:
The sequence is :
33 43 61 93 97 31 53 62 58 87 68 61 16 52 12 29 27 63 68 22
The minimum element in the sequence is : 12
More Java Programs: