Thread: For Loop Counter

  1. #1
    Registered User
    Join Date
    Feb 2012
    Location
    Louisville, Kentucky, United States
    Posts
    2

    For Loop Counter

    Ok, so I need to make a program, that uses a for loop, that will count from a entered value to a second entered value and an entered interval. I am not very good at programming so this is the best I could come up with
    Code:
    int main()
    
    
    {    int count, x, y, z;
    
    
    for(count=x; count<=y ; count=count+z)
    
    
    {
    
    
    
    printf("enter starting value: ", x);
    scanf("%d", &x);
    printf("enter ending value: ", y);
    scanf("%d", &y);
    printf("enter increment: ", z);
    scanf("%d" &z);
    
    
    }
    
    
    return 0;
    
    
    }
    If any one could help me I would be extremely grateful.

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    You need to ask for x, y and z before the beginning of the for loop.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    Registered User
    Join Date
    Feb 2012
    Location
    Louisville, Kentucky, United States
    Posts
    2
    Thank you, that worked perfectly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need help about counter in for loop
    By hasib ahmed in forum C++ Programming
    Replies: 1
    Last Post: 11-07-2011, 01:40 PM
  2. for loop counter problem
    By karipap in forum C Programming
    Replies: 4
    Last Post: 05-05-2009, 07:05 AM
  3. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 03:17 AM
  4. The counter
    By Gordon in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 05:50 AM
  5. Continuous loop or counter problem or both?
    By carolsue2 in forum C++ Programming
    Replies: 4
    Last Post: 04-09-2006, 02:59 AM