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> Date: Tue, 01 Nov 2011 04:37:17 -0500 From: pete 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 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