counting number of integers in sequence

This is a discussion on counting number of integers in sequence within the C++ Programming forums, part of the General Programming Boards category; If I have an algebraic expression that makes a sequance of numbers how do I count the number of integers ...

  1. #1
    Registered User
    Join Date
    Mar 2006
    Posts
    30

    counting number of integers in sequence

    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.

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue w/ Guess My Number Program
    By mkylman in forum C++ Programming
    Replies: 5
    Last Post: 08-23-2007, 01:31 AM
  2. Counting number of lowercase.[NEWBIE]
    By gtr_s15 in forum C++ Programming
    Replies: 18
    Last Post: 11-30-2005, 10:00 PM
  3. Counting the number of lines in a text file - help
    By Erkan in forum C Programming
    Replies: 11
    Last Post: 11-12-2005, 04:12 PM
  4. Counting number from a random file
    By kamisama in forum C Programming
    Replies: 42
    Last Post: 02-22-2005, 04:16 PM
  5. Counting Number of days from year zero
    By wireless in forum C++ Programming
    Replies: 4
    Last Post: 06-16-2002, 07:31 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21