Anyone know how to...

Thelis

Golden Master
Messages
5,410
Using C, find the minimum and maximum numbers in a list using a while loop?
 
I use dark basic which is supposed to be c so i guess its not sorry i can't help you.
 
I can't think of the actual code off the top of my head, but the logic for it will be like this

x=0;
for (listentry=0, listenrty<=siezeof(list), listentry++)
{
if (listentry>=x)
{
x=listentry;
}
}
printf("largest value in list is %f", x);

to do this in a while loop you'll have to use

while (listentry!=EOF)
{
if (listentry>=x)
{
x=listentry;
}
}
printf("largest value in list is %f", x);


(I suggest using a float rather than an int so that you can use decimals as well in your lists)
 
Back
Top Bottom