If I have an algebraic expression that makes a sequance of numbers how do I count the number of integers in the sequence and output this?
The integers are coming from a do-while loop and I don't know how to count them.
If I have an algebraic expression that makes a sequance of numbers how do I count the number of integers in the sequence and output this?
The integers are coming from a do-while loop and I don't know how to count them.
Last edited by rachael033; 05-02-2006 at 09:15 PM.
just create another variable that starts at zero and increment it with each iteration of the loop:Code:#include <iostream> int main() { int iter=0; do{ iter++; std::cout<<iter<<std::endl; }while(true); return 0; }
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT