Examples for finding minimum
Visual Studio 2010 (Similar to VB5, VB6 and Subsequent Visual Basic.NET languages)
In this example it is presumed that the array has already been populated.
A list box is used to output the minimum value. It is possible to use a different object for output.
minimum = testscore[0]For counter = 1 To 9If testscore[counter] ˂ minimum Thenminimum = testscore[counter]End IfNextListBox1.Items.Add ("The minimum value was " & minimum)LiveCode
Remember - Live code will index from 1 rather than 0!
In this example it is presumed that the array has already been populated.
put testscore[1] into minimumrepeat with loop = 2 to 10if testscore[loop] ˂ minimum thenput testscore [loop] into minimumEnd ifend repeatput “The minimum value was" &&minimum&& into field "output"Python – Version 3.x
In this example it is presumed that the array has already been populated.
minimum = testscore[0]for counter in range (1, 10):if testscore[counter] ˂ minimum:minimum = testscore[counter]print ("The minimum value was ", minimum)Java
In this example it is presumed that the array has already been populated.
minimum=testscore[0];for(int counter=1;counter˂10;counter++){if(testscore[counter]˂minimum){minimum=testscore[counter];}}System.out.println("The minimum value was " + minimum);True BASIC
Remember – True BASIC will index from 1 rather than 0!
In this example it is presumed that the array has already been populated.
LET minimum = testscore(1)FOR counter = 2 to 10IF testscore(counter) ˂ minimum THENminimum = testscore (counter)END IFNEXT counterPRINT "The minimum value was "; minimumXojo (Formerly REALbasic)
In this example it is presumed that the array has already been populated.
A static text box called ‘mintext’ has been used to output the minimum value.
minimum = testscore(0)For counter = 1 to 9If testscore(counter)˂minimum Thenminimum = testscore(counter)End IfNextmintext.text = “The minimum value was ” + minimumPascal
In this example it is presumed that the array has already been populated.
beginminimum:=testscore[0];For counter := 1 to 9 dobeginif testscore[counter] ˂ minimum thenminimum:=testscore[counter];end;writeln(output, 'The minimum value was ', minimum);end.Comal
In this example it is presumed that the array has already been populated.
minimum% := testscore% (0)FOR counter%:= 1 TO 9 DOIF testscore% (counter%) ˂ minimum% THENminimum% := testscore% (counter%)ENDIFNEXTPRINT “The minimum value was ”, minimum%