Largest and Smallest Decimal Number Computer program. Can we write a computer program which will find the largest and Smallest Decimal Number in a List? Example: 3.2,4.3,2.1,7.3,5.4,6.3,8.2,1.1,0.8 Thanks & Regards, Prashant S Akerkar 
Yes, that's a pretty straightforward beginning programming exercise. 
You need to define what you mean by largest and smallest. If smallest is most negative then: In Excel: Max( 3.2,4.3,2.1,7.3,5.4,6.3,8.2,1.1,0.8 ) and Min( 3.2,4.3,2.1,7.3,5.4,6.3,8.2,1.1,0.8 ) If smallest means closest to zero, then it becomes marginally more complicated. 
Thanks. Output of the Computer program should be : Largest Decimal Number : 8.2 Smallest Decimal Number : 6.3 Can this be achieved? Thanks & Regards, Prashant S Akerkar 
In what computer language? As Yooklid said, excel has built in functions that do that automatically. If you are asking for a program that uses only the most simple commands then start by setting "max" and "min" equal to a number in the list. Then loop through the list, comparing each number to "max" and "min". If the number is larger than "max", set "max" equal to it. If the number is less than "min", set min equal to it. Suppose your list of numbers is the array "numbers[]" with n members. Then float max, min; max= min= numbers[0]; for (i=0;i< n;i++) { if (numbers[i]> max) then max= numbers[i]; if (numbers[i]< min) then min= numbers[i]; } 
Quote:

All times are GMT 8. The time now is 09:51 PM. 
Copyright © 2019 My Math Forum. All rights reserved.