output every n terms

I did a infinite series program that would output all terms as it ran. How would I change it to output only every 100 terms? Also, if I wanted to output only the terms 5-100?


Is it in a loop? If so just have

1
2
3
4
5
6
 if(loopValue%100==0)
{ 
cout<<value<<endl;

}
crap, I've spent 2 hours trying to figure this out and it was that simple. I got close though.. I knew i had to divide by 100 but didn't think about modulus. Thanks.
Why not try the for loop:

eg:
1
2
3
4
string test[5]={"term1","term2","term3","term4","term5"};

for(int i=1;i<3;i++)
     cout<<test[i];


Programme output:
term2term3term4


Hope it helps,
Aceix.
Last edited on
I thought about doing a for loop earlier but the series uses a for and I didn't want another 1 inside it or anything.
Topic archived. No new replies allowed.