delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/09/17:51:40

Message-ID: <02a301c092ec$09e343c0$6300a8c0@brk>
From: "Johan Henriksson" <jhe AT realsoftware DOT cjb DOT net>
To: <djgpp AT delorie DOT com>
Subject: Re: I think this is a for problem...
Date: Fri, 9 Feb 2001 23:55:58 +0100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

from: Johan Henriksson, leadprogrammer @ www.realsoftware.cjb.net
"The individual should be praised for it's struggle, the society
condemned for it's actions" - me 1997        #12035895
----------------------------------------------------------------------------
-------------------
>"Write a program that finds the smallest of several integers.  Assume that
>the first value read specifies the number of values remaining".
>
>I think I use the for structure.  The chapter also covers the while, and
>switch structures.
>I don't know where to start.  Can anyone help?


Sure, I'm bored anyway. This is actually OT but I generally don't care.
I'm always ready to help if I can.

Pseudostructure:

Take a value (the first one is easiest) and store it
for each other value
 if the other value is below value then
  store it instead


Turned into C-code below (try solve it yourself first!)



















int get_lowest(int *num)
{
int lowest,
     act_num;

lowest=num[1];
for(act_num=1;act_num<num[0];act_num++)
 if(num[act_num]<lowest)
  lowest=num[act_num];
return(lowest);
}


Untested, but it should work. Hope it helps!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019