Subject: Why is everyone talking about martha stewart

From: Star Sightings <[email-masked]>
Date: Wed, 21 May 2014 11:13:17 -0700

In Celebrity News:

Tavern on The Green reopens in New York City with Martha Stewart. 

Doc Oz couldn't help but notice that Martha is looking better than ever. And its looking like 
Tavern on the Green and Martha Stewart both got makeovers.
She's looking 20 yrs younger with this

Did she get plastic surgery? NO .... She did it naturally 
with this ->  / http://www.taskwap.com/celeb/sightings/may/skincare.html

- Celeb Daily Digest
May 15, 2014

You also may like these pics of fresh celeb sightings: / http://www.taskwap.com/celeb/sightings/may/skincare.html

modify your message settings - Urgent Info Services -3205 Lake Sarah
Independence, MN 55359 / http://www.taskwap.com/snmvfoprw.sfgrwi

Can you please tell me why this code is not portable ?   M Sharath Hegde Apr 28 at 5:29
7	  	
@MSharathHegde because it require GCC extension, which is not part of standard and some compiler won't support it   Bryan Chen Apr 28 at 5:31
4	  	
This is the right answer, because it's immediately apparent what the intent is. All those 'clever' answers with modulo are a maintenance nightmare, even with comments.   smirkingman Apr 28 at 9:59
  	  	
@smirkingman Indeed that's what I said in my comment to the main question. It just takes some experience of new coders in a corporate job to realise that the obvious way is often way better than the smart-ninja way.   Richard Le Mesurier Apr 30 at 14:46 First one is easy, you just need to apply the modulo operator to your num value:

if ( ( num % 10 ) == 0)
SInce c++ is evaluating every number that is not 0 as true, you could also write:

if ( ! ( num % 10 ) )  //does not have a residue when devided by 10
For the second one I think this is cleaner to understand:

The pattern repeats every 20, so you can calculate modulo 20. All elements you want will be in a row except the ones that are dividable by 20.

To get those too, just use num-1 or better num+19 to avoid dealing with negative numbers.

if ( ( ( num + 19 ) % 20 ) > 9 )
This is assuming the pattern repeats forever, so for 111-120 it would apply again, and so on. Otherwise you need to limit the numbers to 100:

if ( ( ( ( num + 19 ) % 20 ) > 9 ) && ( num <= 100 ) ) he first comment is unneeded. Any programmer with a little experience will know that num % 10 == 0 is the same thing as num is a multiple of 10.   Quincunx Apr 28 at 17:39
5	  	
yes but beginners read this site too. I wouldn't normally use that comment in my own code but it does make the answer clearer to the beginners who would benefit from this beginner question.   La-comadreja Apr 28 at 17:43
  	  	
Please don't ever do this. It actually reduces readability, by slowing down the reader and forcing them to read everything twice. Any programmer who doesn't understand that if (num % 10 == 0) means the same as // Check if it's a multiple of 10 should not be maintaining your code. This is a well-known anti-pattern.   David Wallace May 8 at 19:17 
  	  	
@DavidWallace see comment above. We can't guarantee that the readers of this post will know this anti-pattern.   La-comadreja May 9 at 15:34 
  	  	
No, I mean that commenting each line to say what it does is an anti-pattern. I don't mean that using % is an anti-pattern; obviously it is not. Really, assuming that many of the readers of this post will be beginners, teaching them this style of writing comments is making a negative contribution to their development as programmers.   David Wallace May 9 at 19:55