Thread: Pausing a loop

  1. #1
    bpc8891
    Guest

    Pausing a loop

    Very new to programming and I am trying to get a program to retrieve a file and number it if it has more than 24 lines of info it should stop until prompted by the user. I know it needs a loop but how do I retain the numbers i.e. 1-24 then 25-49.....

  2. #2
    Shadow12345
    Guest
    in case you don't know what '%' means, it is modulus, and it returns the remainder of the division of two numbers

    so this means the remainder of linenum divided by 24 will be 0 every 24 lines
    47 / 24 = 1.958; //has a remainder of .958 so it doesnt work
    48 / 24 = 2; //has no remainder so it works, yay!

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    The remainder and the decimal part of the quotient aren't equivalent.
    The remainder is an integer.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    booyakasha
    Join Date
    Nov 2002
    Posts
    208
    The remainder of 47 / 24 is 23

  5. #5
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    or .04
    Monday - what a way to spend a seventh of your life

  6. #6
    Registered User
    Join Date
    Aug 2002
    Posts
    6

    no

    Its just 23. I dont know where you got .4 from. Could you explain?

  7. #7
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    Code:
    if(wherey()%24==0)
    {
       cout<<"Press a key..."; getch();
    }
    //continue execution.
    Include conio.h and iostream.h

    Compiler : Turbo C++ v1.01.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My loop within loop won't work
    By Ayreon in forum C Programming
    Replies: 3
    Last Post: 03-18-2009, 10:44 AM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 02:14 AM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM
  5. when a while loop will stop ?
    By blue_gene in forum C Programming
    Replies: 13
    Last Post: 04-20-2004, 03:45 PM