need help about counter in for loop

This is a discussion on need help about counter in for loop within the C++ Programming forums, part of the General Programming Boards category; i cant under stand the counter in the for loop for example in a simple Code: #include<iostream.h> #include<conio.h> void main() ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    1

    need help about counter in for loop


    i cant under stand the counter in the for loop for example in a simple
    Code:
    #include<iostream.h>
    #include<conio.h>
    void main()
    {
       clrscr();
       int n,count=0;
       cout<<"enter the intiger";
       cin>>n;
       for(int i=1;i<=n;i++)
        {
          if(n%i==0)
          {
            count++;
            cout<<count;
             }
          }
        getch();
    }
    this program shows N divides how much numbers like if input is 8 then out put is 4 because 8divided by 1,2,4 or 8.
    my question is how can i see the 1,2,4,8 insted of 4.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,799
    Instead of outputting the count output i within the loop.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. for loop counter problem
    By karipap in forum C Programming
    Replies: 4
    Last Post: 05-05-2009, 07:05 AM
  2. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 02:17 AM
  3. Continuous loop or counter problem or both?
    By carolsue2 in forum C++ Programming
    Replies: 4
    Last Post: 04-09-2006, 02:59 AM
  4. Help With a Counter
    By Halo in forum C++ Programming
    Replies: 3
    Last Post: 12-15-2005, 03:03 PM
  5. Help!Counter...
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 05-25-2002, 01:14 AM

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