Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <vg0hhn$2psrf$1@dont-email.me>
Deutsch   English   Français   Italiano  
<vg0hhn$2psrf$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: James Kuyper <jameskuyper@alumni.caltech.edu>
Newsgroups: comp.lang.c
Subject: Re: else ladders practice
Date: Thu, 31 Oct 2024 14:16:23 -0400
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <vg0hhn$2psrf$1@dont-email.me>
References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org>
 <20241031161545.aed6541ce6c728923a46e9df@g{oogle}mail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Oct 2024 19:16:24 +0100 (CET)
Injection-Info: dont-email.me; posting-host="87a4c51cf7062a366aefdad36ea7a07f";
	logging-data="2945903"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18eZ54xDdEV2BbemxP8PjGqlIFVkDa/Xjw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:s6s8m6h1QNEdrZBEOlljkmEQJIY=
In-Reply-To: <20241031161545.aed6541ce6c728923a46e9df@g{oogle}mail.com>
Content-Language: en-US
Bytes: 2097

On 10/31/24 09:15, Anton Shepelev wrote:
> fir:
> 
>> somethins i got such pies of code like
>>
>> if(n==1) {/*something/}
>> if(n==2) {/*something/}
>> if(n==3) {/*something/}
>> if(n==4) {/*something/}
>> if(n==5) {/*something/}
>>
>> technically i would need to add elses
> 
> Why?

He has indicated that the value of n is not changed inside any of the
if-clauses. A sufficiently sophisticated compiler could notice that
fact, and also that each of the conditions is on the same variable, and
as a result it could generate the same kind of code as if it had been
written with 'else', so it won't generate unnecessary condition tests.
It might, in fact, generate the same kind of code which would have been
generated if it had been coded properly, as a switch statement, so it
might use a jump table, if appropriate.
But it's better to write it as a switch statement in the first place, so
you don't have to rely upon the compiler being sufficiently
sophisticated to get the best results.