/**
* Find the minimum and maximum number in a given array.
*
* Approach: we can pick an element from array and compare with the min and max value
*
*
*/
public class MinMaxNumber {
public static void main(String[] args) {
int arr[] = {1100,10,3,5,8,1,5,9,23,56,0,90,54};
int min,max;
min=max= arr[0];
for(int i =1 ; i<arr.length;i++){
if (min > arr[i]){ // comparing the number for min value
min= arr[i];
}
if(max < arr[i]){ // comparing the number for max value
max=arr[i];
}
}
System.out.println("Min value = " + min);
System.out.println("Max value = " + max);
}
}
/* output
Min value = 0
Max value = 1100
A blog about new technology, Android, iOS, Mobile Automation, Appium, Web Automation, Selenium, JAVA, Shell Scipting, Powershell, Testing Tools, QA, Spring Boot, Free Software, How to design best frameworks etc..
Java : Program to find the minimum and maximum number in a given array.
Subscribe to:
Post Comments (Atom)
πAnnouncement : Visit the new website/blog π
πππ Announcement : Visit the new website/blog πππ Dear readers, Thank you for reading my blog. If you could have used the little info...
-
How to find the UDID of Android Device What is UDID : It stands for Unique Device Identifier. UDID is required duri...
-
How to change language of device using commandLine Changing language in Android device on-the fly is needed when we are running or exe...
-
To setup Appium for mobile automation, you will need below items to be configured in your test environment. 1. Appium server : 1.1 D...
-
How to get the package name of Android application There are multiple ways in which we can obtain the package name of Android .apk file. ...
No comments:
Post a Comment