Deutsch English Français Italiano |
<vto4qu$23kmr$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Wed, 16 Apr 2025 12:38:07 +0100 Organization: A noiseless patient Spider Lines: 31 Message-ID: <vto4qu$23kmr$2@dont-email.me> References: <vtc19j$2kqlj$1@dont-email.me> <87a58mqt2o.fsf@nosuchdomain.example.com> <vtc7mp$2q5hr$1@dont-email.me> <vtcqf6$3j95s$1@dont-email.me> <vtdh4q$b3kt$1@dont-email.me> <vtf7fe$1qtpg$1@dont-email.me> <vtgfuf$31ug1$1@dont-email.me> <20250413072027.219@kylheku.com> <vtgpce$39229$1@dont-email.me> <vti2ki$g23v$1@dont-email.me> <vtin99$vu24$1@dont-email.me> <vtiuf0$18au8$1@dont-email.me> <vtj97r$1i3v3$1@dont-email.me> <vtl166$36p6b$1@dont-email.me> <vtlcg0$3f46a$2@dont-email.me> <ad1vvjtvk7ppgdfdp047uk60o13j0jvr13@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 16 Apr 2025 13:38:07 +0200 (CEST) Injection-Info: dont-email.me; posting-host="507c987f563baeac8cb4b74b82477869"; logging-data="2216667"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+43JJRP0QXzrjNhImniguM" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:mxqdgXi7rObc2nUKaBW+Gl2GAv8= In-Reply-To: <ad1vvjtvk7ppgdfdp047uk60o13j0jvr13@4ax.com> Content-Language: en-GB Bytes: 2313 On 16/04/2025 11:29, Rosario19 wrote: > On Tue, 15 Apr 2025 11:30:24 +0100, bart wrote: > >> for (i=0 i<=N; ++i) >> >> Most such loops iterate over 0..N-1 inclusive, so would need "<". So, in >> your opinion, is that <= a typo, or is the intention to iterate over >> 0..N inclusive (so N+1 iterations)? >> >> >> (May reply to rest separately.) > > the loop enter with i=0 > than make i= 1..N N in the count > so would be N+1 times iterations > that are 0..N or 0,1,2,3...,N > > <= is not a Typo > > i not find the problem > No? What about here: enum {N=10}; int A[N]; for (int i=0; i <= N; ++i) A[i] = i; Is there still no problem? Except this will be in the middle of 1000 lines of busy code with longer identifiers and more elaborate expressions.