tag:blogger.com,1999:blog-8712770457197348465.post3712460207359010273..comments2023-03-31T05:22:35.901-07:00Comments on Javarevisited: How to Find Largest and Smallest of N numbers without using Array in Java? Examplejavin paulhttp://www.blogger.com/profile/15028902221295732276noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-8712770457197348465.post-60506386997702486782020-08-02T10:21:40.071-07:002020-08-02T10:21:40.071-07:00how it is finding the min and max value as we are ...how it is finding the min and max value as we are entering no for example 3 4 6 , it has to be store all the no in largest and smallest because all the no we are entering it is less than the Integer.MaxValue and greater than the Integer.MinValue. So why only 6 no is saving in largest variable not in smallest variable as it is also lesser than Integer.MAXVALUE! so it has to also store in smallestAnonymoushttps://www.blogger.com/profile/11531914937995417270noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-15757031024702068712019-09-14T02:09:15.876-07:002019-09-14T02:09:15.876-07:00Hello Clement, we are starting with the smallest p...Hello Clement, we are starting with the smallest possible value for integer in Java. javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-32452753018051208922019-09-13T04:32:19.303-07:002019-09-13T04:32:19.303-07:00hi, may i know whats the reasoning for largest= In...hi, may i know whats the reasoning for largest= Integer.MIN_VALUE and smallest= Integer.MIN_VALUEClement Lohhttps://www.blogger.com/profile/11451564871387340089noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-6113499369762847252017-09-17T02:50:43.283-07:002017-09-17T02:50:43.283-07:00I think this algorithm is incorrect. Because i ent...I think this algorithm is incorrect. Because i entered 4 7 2 1 8 like that and <br />result is <br />largest of N number is : -2147483648<br />smallest of N number is : 1Anonymoushttps://www.blogger.com/profile/17331119582009421325noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-58415526355009832642016-07-11T08:46:41.981-07:002016-07-11T08:46:41.981-07:00@Ashish and @Anonymous, good catch, it should be e...@Ashish and @Anonymous, good catch, it should be either else or just a simple if instead of else if. Corrected now. Thanks for pointing it out.javin paulhttps://www.blogger.com/profile/15028902221295732276noreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-26249897215223441242016-07-05T22:02:50.406-07:002016-07-05T22:02:50.406-07:00if (current > largest) {
largest = curr... if (current > largest) {<br /> largest = current;<br /> } if (current < smallest) {<br /> smallest = current;<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8712770457197348465.post-80845081241028493692016-07-03T08:54:45.706-07:002016-07-03T08:54:45.706-07:00if i give input n=4 and 1,2,3,4 then output will b...if i give input n=4 and 1,2,3,4 then output will be <br />largest of N number is : 4<br />smallest of N number is : 2147483647<br /><br />but it should be <br />largest of N number is : 4<br />smallest of N number is : 1<br /><br />We can use else instead of else ifAshish Agarwalhttps://www.blogger.com/profile/06257361946396435667noreply@blogger.com