Thread: While Loop

  1. #1

    While Loop

    I am writing a program that calculates employee bonuses based on several criteria. My last requirement is that I embed the code in a loop that allows an indeterminate number of employees and their information to be input and the bonuses calculated... does someone have an idea of how I might do this. I think that I need a while or a do while loop, but I am not sure. thanks for the help

  2. #2
    Registered User breed's Avatar
    Join Date
    Oct 2001
    If the loop is undetermined , try using a sentinell value like XXXXX
    or 99999
    #define LAST XXXXX


    //during some coding
    //test for LAST

    }while(record != LAST);
    Before you judge a man, walk a mile in his
    shoes. After that, who cares.. He's a mile away and you've got
    his shoes.
    ************William Connoly

  3. #3
    Join Date
    Aug 2001
    Groningen (NL)
    >indeterminate number of employees

    You should define some end-code. If the user gives this end-code as input, then the end of input is reached.

    #define END_CODE 1
    code = 0;
    while (code != 1)
        /* let the user input a code */

  4. #4
    Registered User
    Join Date
    Jan 2002
    That's strange. I have a program due thrusday with those exact same requirements. S215 rules.

    You should probably ask the user "Calculate another bonus(Y/N)?" and terminate the loop if N is entered.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 02:14 AM
  3. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 12:38 PM
  4. while loop help
    By bliznags in forum C Programming
    Replies: 5
    Last Post: 03-20-2005, 12:30 AM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM