Deutsch   English   Français   Italiano  
<86frnqrmsh.fsf@linuxsc.com>

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

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder2.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: else ladders practice
Date: Sun, 17 Nov 2024 05:51:26 -0800
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <86frnqrmsh.fsf@linuxsc.com>
References: <3deb64c5b0ee344acd9fbaea1002baf7302c1e8f@i2pn2.org> <slrnvi746p.fkp.dan@djph.net> <else-20241116103316@ram.dialup.fu-berlin.de> <vhae7k$2j8e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 17 Nov 2024 14:51:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c7addf0a575b264d060ba5f0cab1431f";
	logging-data="698414"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18BdftzXQmORxQtq8npFpgsVqbyBalDdkw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:HpthxTWJq72MScX2Q0Wd0VrOmNc=
	sha1:09yDK24SRL6hBiCWeDE7h8n0Qvw=
Bytes: 2696

Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:

> On Sat, 16 Nov 2024 09:42:49 +0000, Stefan Ram wrote:
>
>> Dan Purgert <dan@djph.net> wrote or quoted:
>>
>>> if (n==0) { printf ("n: %u\n",n); n++;}
>>> if (n==1) { printf ("n: %u\n",n); n++;}
>>> if (n==2) { printf ("n: %u\n",n); n++;}
>>> if (n==3) { printf ("n: %u\n",n); n++;}
>>> if (n==4) { printf ("n: %u\n",n); n++;}
>>> printf ("all if completed, n=%u\n",n);
>>
>>   My bad if the following instruction structure's already been hashed
>>   out in this thread, but I haven't been following the whole convo!
>>
>>   In my C 101 classes, after we've covered "if" and "else",
>>   I always throw this program up on the screen and hit the newbies
>>   with this curveball:  "What's this bad boy going to spit out?".
>>
>>   Well, it's a blue moon when someone nails it.  Most of them fall
>>   for my little gotcha hook, line, and sinker.
>>
>> #include <stdio.h>
>>
>> const char * english( int const n )
>> { const char * result;
>>   if( n == 0 )result = "zero";
>>   if( n == 1 )result = "one";
>>   if( n == 2 )result = "two";
>>   if( n == 3 )result = "three";
>>   else        result = "four";
>>   return result; }
>>
>> void print_english( int const n )
>> { printf( "%s\n", english( n )); }
>>
>> int main( void )
>> { print_english( 0 );
>>   print_english( 1 );
>>   print_english( 2 );
>>   print_english( 3 );
>>   print_english( 4 ); }
>
> If I read your code correctly, you have actually included not one,
> but TWO curveballs.  Well done!

What's the second curveball?