0% found this document useful (0 votes)
23 views

LAB Task04minmax

The document describes a Java program that randomly generates and stores 10 integers between 1-100 in an array. It then finds the minimum and maximum values in the array without sorting. The program initializes the min and max variables, generates random numbers for the array elements, compares each element to min and max, and finally prints out the minimum, maximum and student name and roll number.

Uploaded by

tayyaba hussain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

LAB Task04minmax

The document describes a Java program that randomly generates and stores 10 integers between 1-100 in an array. It then finds the minimum and maximum values in the array without sorting. The program initializes the min and max variables, generates random numbers for the array elements, compares each element to min and max, and finally prints out the minimum, maximum and student name and roll number.

Uploaded by

tayyaba hussain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

OOP-Object oriented programming tayyaba munawar-032

LAB NO: 04
LAB TASK:

OBJECTIVE: Write a program that can fill an array of 10 elements by randomly generates Integers, range (1-100).
Find the Minimum and Maximum values without sorting the array.

SOURCE PROGRAM:

public class minmax{

public static void main (String[] args){

int array [] = new int [10];

int min;

int max;

for(int i=0;i<10;i++){

array[i]=(int)(Math.random()*9+19);

System.out.println(array[i]);}

min=array[0];

max=array[0];

for(int i=1;i<10;i++){

if(min>array[i])

min=array[i];

if(max<array[i])

max=array[i];}

System.out.println("Minimum of the Array :"+ min);

System.out.println("Maximum of the Array :"+ max);

System.out.println("\nName: tayyaba munawar \nRoll no: 32");

Page | 1
OOP-Object oriented programming tayyaba munawar-032

OUTPUT:

Page | 2

You might also like