
Applied Math Applied Math Forum 
 LinkBack  Thread Tools  Display Modes 
March 20th, 2017, 09:35 AM  #1 
Banned Camp Joined: Aug 2011 Posts: 534 Thanks: 2  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 
March 20th, 2017, 09:49 AM  #2 
Senior Member Joined: Aug 2012 Posts: 2,259 Thanks: 685 
Yes, that's a pretty straightforward beginning programming exercise.

March 21st, 2017, 10:43 AM  #3 
Senior Member Joined: Jul 2008 From: Western Canada Posts: 5,063 Thanks: 46 
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. 
March 21st, 2017, 10:31 PM  #4 
Banned Camp Joined: Aug 2011 Posts: 534 Thanks: 2 
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 
March 31st, 2017, 05:28 AM  #5 
Math Team Joined: Jan 2015 From: Alabama Posts: 3,264 Thanks: 902 
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]; } 
March 31st, 2017, 06:46 AM  #6 
Senior Member Joined: Apr 2014 From: Glasgow Posts: 2,150 Thanks: 730 Math Focus: Physics, mathematical modelling, numerical and computational solutions  

Tags 
computer, decimal, largest, number, program, smallest 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Finding Smallest & Largest Possible Values  Shamieh  Calculus  2  October 22nd, 2013 10:00 AM 
Find the smallest and largest value of this function  dragon  Calculus  1  December 12th, 2012 08:55 AM 
the largest and smallest number remained  Albert.Teng  Algebra  0  October 7th, 2012 11:32 PM 
largest set vs smallest set  gurkan  Applied Math  3  August 27th, 2012 04:50 PM 
Largest and smallest volumes  nikki1234  Calculus  7  May 3rd, 2011 03:50 PM 