🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #804

Re: Taming The Switch-Statement

#804
From: fir
Date: Mon, 26 Oct 2026 17:37
115 lines
4214 bytes
fir pisze:
> fir pisze:
>> bartc pisze:
>>> On 26/10/2026 16:45, fir wrote:
>>>> bartc pisze:
>>>>>> without or (or something analogic) as i understand if im not wrong 
>>>>>> you cant
>>>>> You seem fixated on that 'or'. Either use 'else', or create 'or' as 
>>>>> an alias as I suggested.
>>>>
>>>> imo you should try to understand the example
>>>>
>>>> for(int i = 1; i < 20; i++)
>>>> {
>>>>
>>>>          if(x%2==0) printf("\n divides by 2");
>>>>       or if(x%3==0) printf("\n divides by 3");
>>>>       else  printf("\n no divides (by 2 or 3)");
>>>> }
>>>>
>>>> you understand how this would work? i think you do
>>>>
>>>> and how in normal c without this "or" it would look,
>>>> for exampel in your if else model?
>>>
>>> Show me exactly what the output should be, when it is written like this:
>>>
>>>            if(x%2==0) printf("\n%d divides by 2", i);
>>>         or if(x%3==0) printf("\n%d divides by 3", i);
>>>         else  printf("\n%d no divides (by 2 or 3)", i);
>>>
>>> You might also want to look at the FizzBuzz program.
>>>
>> 1 no divides (by 2 or 3)
>> 2 divides by 2
>> 3 divides by 3
>> 4 divides by 2
>> 5 no divides (by 2 or 3)
>> 6 divides by 2
>> 6 divides by 3
>> 7 no divides (by 2 or 3)
>> 8 divides by 2
>> 9 divides by 3
>> 10 divides by 2
>> 11 no divides (by 2 or 3)
>> 12 divides by 2
>> 12 divides by 3
>> 13 no divides (by 2 or 3)
>> 14 divides by 2
>> 15 divides by 3
>> 16 divides by 2
>> 17 no divides (by 2 or 3)
>> 18 divides by 2
>> 18 divides by 3
>> 19 no divides (by 2 or 3)
>>
> 
> 
> 
> in fact i had more such in my mind
> 
> for(int i=0; i<20; i++)
> {
> printf("\n %d,i);
> if(x%2==0) printf("\n divides by 2");
>   or if(x%3==0) printf("\n divides by 3");
>   else printf("\n no divides (by 2 or 3)");
> 
> }
> 
> so the output is
>   1
>   no divides (by 2 or 3)
>   2
>   divides by 2
>   3
>   divides by 3
>   4
>   divides by 2
>   5
>   no divides (by 2 or 3)
>   6
>   divides by 2
>   divides by 3
>   7
>   no divides (by 2 or 3)
>   8
>   divides by 2
>   9
>   divides by 3
>   10
>   divides by 2
>   11
>   no divides (by 2 or 3)
>   12
>   divides by 2
>   divides by 3
>   13
>   no divides (by 2 or 3)
>   14
>   divides by 2
>   15
>   divides by 3
>   16
>   divides by 2
>   17
>   no divides (by 2 or 3)
>   18
>   divides by 2
>   divides by 3
>   19
>   no divides (by 2 or 3)
> 

...and.....?
Technical Details
Message-ID: <11bo33v$qaa9$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me> <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me> <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me> <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me> <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me> <11bo1bc$phlr$1@dont-email.me> <11bo1jf$phlr$2@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: Mon, 26 Oct 2026 18:37:04 +0100
Organization: A noiseless patient Spider
Lines: 115
Message-ID: <11bo33v$qaa9$1@dont-email.me>
References: <119qf6l$2rmg3$1@dont-email.me> <11ba02r$3pl5h$1@dont-email.me>
 <11bnfpm$i84l$1@dont-email.me> <11bng23$iblc$1@dont-email.me>
 <11bngj1$ifj5$1@dont-email.me> <11bnnbg$l7i1$1@dont-email.me>
 <11bntk0$nsbo$1@dont-email.me> <11bnvbq$olbj$1@dont-email.me>
 <11bo02r$otr5$1@dont-email.me> <11bo0ul$pbso$1@dont-email.me>
 <11bo1bc$phlr$1@dont-email.me> <11bo1jf$phlr$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 26 Oct 2026 17:37:04 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="862537"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19su4UGRi1DZsMqjHHK5fXd7fTUiFpbTvo="; posting-host="524fd3863234ce524468884467e01d13"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:7yBODECYursPMVOBrdFnpjflpiQ= sha256:7Bl/Ws9I6QxbzH3de804JCQYnyhSl9eI0YAsMIdTPgw=
	sha1:pU82aH0o2TIEiIYE6srglDLrkSc= sha256:HQtF7/iTHYR1FLepdSi9GdzzrbcihqFFqr6m52vvezc=
In-Reply-To: <11bo1jf$phlr$2@dont-email.me>