Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c |
| Subject | Re: (simple) condition within for loop |
| Date | Mon, 13 Jun 2011 11:27:07 +1200 |
| Lines | 49 |
| Message-ID | <95l0abFrhmU6@mid.individual.net> (permalink) |
| References | <582385e0-5f22-49d2-9703-e8f591c9927b@y30g2000yqb.googlegroups.com> <laiav6t16tk5vi9k9n96qs20qnqmrnn1kv@4ax.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net yR+5EP6Rulxx43jYPT9cPwkuSIYicdb/8PJML55qtJrExPbmUA |
| Cancel-Lock | sha1:6UKkSxIKdWENJdmNw00hNR/R6ms= |
| User-Agent | Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 |
| In-Reply-To | <laiav6t16tk5vi9k9n96qs20qnqmrnn1kv@4ax.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c:5936 |
Show key headers only | View raw
On 06/13/11 11:24 AM, Geoff wrote:
> On Sun, 12 Jun 2011 15:58:44 -0700 (PDT), papoupapa
> <papoupapoug@gmail.com> wrote:
>
>> Hi,
>>
>> The code below doesn't read the condition that says to stop when the
>> entry is 0. A while loop might be more convenient....
>>
>>
>> #include<stdio.h>
>>
>> #define CMAX 5
>>
>> int main(void)
>> {
>> int Numbers[CMAX] ;
>> int nbr_in ;
>> int i, j ;
>>
>> nbr_in = 1 ;
>> j = 0 ;
>> for (i = 0 ; (nbr_in != 0) || (i< CMAX) ; i++, j++)
>> {
>> printf("\nValue %d : ", i+1) ;
>> scanf("%d",&nbr_in) ;
>> Numbers[i] = nbr_in ;
>> }
>>
>> printf("\n\nOUTPUT : \n") ;
>>
>> for (i = 0 ; ((Numbers[i] != 0) || (i< CMAX)) ; i++)
>> printf("\n%d. : %d", i+1, Numbers[i]) ;
>>
>> printf("\n\n") ;
>> return 0 ;
>> }
>>
>> Thanks in advance,
>
> Read your text about 'for' loops and the 'break' statement.
> Test conditionals with 'if' as in "if (num_in == 0)".
> Use the same technique for both loops.
Why? What's wrong with testing more than one condition in a for loop
(assuming the logic is correct!)?
--
Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
(simple) condition within for loop papoupapa <papoupapoug@gmail.com> - 2011-06-12 15:58 -0700
Re: (simple) condition within for loop Ian Collins <ian-news@hotmail.com> - 2011-06-13 11:08 +1200
Re: (simple) condition within for loop Geoff <geoff@invalid.invalid> - 2011-06-12 16:24 -0700
Re: (simple) condition within for loop Ian Collins <ian-news@hotmail.com> - 2011-06-13 11:27 +1200
Re: (simple) condition within for loop Geoff <geoff@invalid.invalid> - 2011-06-12 16:47 -0700
Re: (simple) condition within for loop Ian Collins <ian-news@hotmail.com> - 2011-06-13 12:01 +1200
Re: (simple) condition within for loop Geoff <geoff@invalid.invalid> - 2011-06-12 19:51 -0700
Re: (simple) condition within for loop papoupapa <papoupapoug@gmail.com> - 2011-06-13 06:00 -0700
Re: (simple) condition within for loop Willem <willem@toad.stack.nl> - 2011-06-13 14:39 +0000
Re: (simple) condition within for loop "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-13 22:13 +0100
Re: (simple) condition within for loop Geoff <geoff@invalid.invalid> - 2011-06-13 17:13 -0700
Re: (simple) condition within for loop Tim Rentsch <txr@alumni.caltech.edu> - 2011-06-14 15:58 -0700
Re: (simple) condition within for loop Nobody <nobody@nowhere.com> - 2011-06-13 02:32 +0100
Re: (simple) condition within for loop "Herbert Rosenau" <os2guy@pc-rosenau.de> - 2011-06-14 06:41 +0000
csiph-web