similar with Question_2

PHOTO EMBED

Tue May 30 2023 18:49:12 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

int[]myArray={1,2,33,56,34,85,32};

 //find maximum number in the array

        int max=0;
        for(int i=0;i<myArray.length;i++)
        {
            if (myArray[i]>max)
            {
                
                max=myArray[i];
            }
        }
        
        System.out.println("maximum num in the array is = " + max);
//find second largest number in the array
        
        int secondLargest = 0;
        
        for(int i=0; i<myArray.length; i++) {
        	if(myArray[i] < max && myArray[i] > secondLargest) {
        		secondLargest = myArray[i];
        	}
        }
        System.out.println("The second Largest num in the array is = " + secondLargest);

//find third largest numbr in the array.
        int thirdLargest = 0;
        for(int i=0; i<myArray.length; i++) {
        	if(myArray[i]< secondLargest && myArray[i]> thirdLargest) {
        		thirdLargest = myArray[i];
        	}
        }
content_copyCOPY