While Loop

This is a discussion on While Loop within the C Programming forums, part of the General Programming Boards category; I am writing a program that calculates employee bonuses based on several criteria. My last requirement is that I embed ...

  1. #1
    Unregistered
    Guest

    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
    Posts
    91
    If the loop is undetermined , try using a sentinell value like XXXXX
    or 99999
    #define LAST XXXXX

    do
    {


    //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
    Location
    Groningen (NL)
    Posts
    2,386
    >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.

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

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    2
    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, 11:21 PM
  2. While loop misbehaving (or misunderstanding)
    By mattAU in forum C Programming
    Replies: 2
    Last Post: 08-28-2006, 03:14 AM
  3. loop in a linked linked lists
    By kris.c in forum C Programming
    Replies: 6
    Last Post: 08-26-2006, 01: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

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