By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,811 Members | 785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,811 IT Pros & Developers. It's quick & easy.

Finding every nth number in an array set

P: 8
How would I go about finding every nth number in an array set? For example if i had a set containing the numbers 1-100 int each cell, how would I go about finding every 3rd number in the set.
Oct 26 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 469
Use a for loop, but instead of incrementing the counter variable by one each time, add three to it.
Hope this helps.
Oct 26 '08 #2

P: 542
Yes as boxfish says instead of for(i=0;i<sardines; i++) the increment i++ could be expressed as i+=3
Oct 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.