Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Tue, 01 Nov 2011 04:37:12 -0500 |
| Message-ID | <4EAFBDCD.7264@mindspring.com> (permalink) |
| Date | Tue, 01 Nov 2011 04:37:17 -0500 |
| From | pete <pfiland@mindspring.com> |
| Reply-To | pfiland@mindspring.com |
| Organization | PF |
| X-Mailer | Mozilla 3.04Gold (WinNT; I) |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.c |
| Subject | Re: Using ternary and summing array |
| References | <26bf4806-b232-4878-810b-55f3d3926c9f@p20g2000prm.googlegroups.com> <6615b0de-8283-486e-acaf-fa21560ff96d@p14g2000pra.googlegroups.com> |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| Lines | 15 |
| X-Usenet-Provider | http://www.giganews.com |
| NNTP-Posting-Host | 4.154.219.66 |
| X-Trace | sv3-vNw1Y8oPRWd4iE/ySXA4bPWNFYJIR8J2jwx8RmQ+POjMZtYvB0z2H17/uk0WYh/tCLgU+7L88K3eEca!FT1rCQkkWfWD1Lm8EH4wuaK7UxUEWuMGc4Er/dei42pxKX/cnKzfBxOwXbKKaq3ZLjMzIwhgiFWD!8kg1OmgSTg== |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| X-Original-Bytes | 1450 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c:12431 |
Show key headers only | View raw
flebber wrote:
> I created a working solution with an if statement but I would still
> really love to know if I could use the "?" to acheive the same result.
> if ((i % 3 == 0)||(i % 5 == 0)){
> sum += i;
> }
If that is truly your goal:
sum += ((i % 3 == 0)||(i % 5 == 0)) ? i : 0;
--
pete
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Using ternary and summing array flebber <flebber.crue@gmail.com> - 2011-10-31 03:35 -0700
Re: Using ternary and summing array flebber <flebber.crue@gmail.com> - 2011-10-31 04:06 -0700
Re: Using ternary and summing array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-10-31 15:06 +0000
Re: Using ternary and summing array pete <pfiland@mindspring.com> - 2011-11-01 04:37 -0500
Re: Using ternary and summing array Keith Thompson <kst-u@mib.org> - 2011-11-01 16:36 -0700
Re: Using ternary and summing array flebber <flebber.crue@gmail.com> - 2011-10-31 04:04 -0700
Re: Using ternary and summing array Jean-Christophe <5.d@free.fr> - 2011-10-31 04:16 -0700
Re: Using ternary and summing array Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-10-31 15:00 +0000
Re: Using ternary and summing array flebber <flebber.crue@gmail.com> - 2011-10-31 16:11 -0700
Re: Using ternary and summing array James Kuyper <jameskuyper@verizon.net> - 2011-10-31 21:49 -0400
Re: Using ternary and summing array Kenneth Brody <kenbrody@spamcop.net> - 2011-11-03 12:04 -0400
Re: Using ternary and summing array Kaz Kylheku <kaz@kylheku.com> - 2011-11-03 17:03 +0000
Re: Using ternary and summing array Kenneth Brody <kenbrody@spamcop.net> - 2011-11-08 13:08 -0500
Re: Using ternary and summing array James Kuyper <jameskuyper@verizon.net> - 2011-10-31 07:46 -0400
Re: Using ternary and summing array David Thompson <dave.thompson2@verizon.net> - 2011-11-21 02:39 -0500
csiph-web