In what language?
get first input and save it in intLow and intHigh
for i = 1 to 10
get input into variable intInput
if intInput < intLow save intInput into intLow
if intInput > intHigh and intHigh
end for
print intLow and intHigh
2006-09-21 10:31:04
·
answer #1
·
answered by andalucia 3
·
1⤊
0⤋
You didn't say how the integers are being entered and what language you are using.
Let's assume we have a fixed array of integers $integers and we have defined if necessary $smallest and $largest
for (a=0, a<= $numOfIntegers, a++)
{
if (a == 0)
{
$smallest = $integers[a];
$largest = $integers[a];
}
if ($smallest > $integers[a])
{
$smallest = $integers[a];
}
if ($largest < integers[a])
{
$largest = $integers[a]
}
}
You can adapt this to your language and then display $largesst and $smallest. If you need to enter the integers in reeal time, you will need to replace the array with input and use a while loop or something similar. Best I can do with the information you gave
2006-09-21 17:36:20
·
answer #2
·
answered by teef_au 6
·
0⤊
0⤋
Which programming language do you want to write the code in?
2006-09-21 17:29:12
·
answer #3
·
answered by SmartSpider 4
·
1⤊
0⤋
what language?
in c/c++ it could look something like:
int counter = 1;
int highest = 0;
int lowest = 0,
int entry;
for (counter; counter<=10; counter++){
/*get entry*/
/*check if entry is lower than lowest or higher than highest and replace as necessary*/
}/*end of for loop*/
/*print results*/
2006-09-21 17:38:11
·
answer #4
·
answered by John J 6
·
0⤊
0⤋
Why use a for loop at all?
var myArr = [1,2,3,4,5,6,7,8];
alert("Lowest: " + myArr[0] + "\nHighest: " + myArr[myArr.length - 1]);
2006-09-21 20:05:43
·
answer #5
·
answered by jnicora2002 2
·
0⤊
1⤋
see here:
http://en.wikipedia.org/wiki/Bubble_sort
2006-09-21 17:55:30
·
answer #6
·
answered by Nick F 6
·
0⤊
0⤋