Thread: Help with symbolic constants

  1. #16
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    This shows what I am trying to describe:

    Code:
    if (hours > STD_HOURS)
    {
        overtime = hours - STD_HOURS;
        overtime_pay = overtime * (wage + (wage / 2));
        gross = wage * STD_HOURS + overtime_pay;
    }
    else
    {
        overtime = ?
        overtime_pay = ?
        gross = ?
    }

  2. #17
    Registered User
    Join Date
    Aug 2012
    Posts
    22
    so in the else I am going to put the overtime and overtime_pay variable and initialize them to 0. Correct?

  3. #18
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Try it and tell us if it solves the problem =)

  4. #19
    Registered User
    Join Date
    Aug 2012
    Posts
    22
    Hey well whaddya know... it works. I think the way you put it is more elegant and more easier to read and that is the objective.
    Hey Thanks much and if I can rep you or whatever on this forum, let me know.

  5. #20
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    Flowers would be nice.
    Seriously, though, it was my pleasure to assist. For someone who is relatively new to programming (and these forums), you write good code, have a good consistent indentation style, and a seeming desire to learn. That's not as common around here as is should be, and it's nice when it happens.

  6. #21
    Registered User
    Join Date
    Aug 2012
    Posts
    22
    Help with symbolic constants-cone-flowers-preview-jpg

    Flowers sent ^^^^^^

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Symbolic vs Descriptive
    By audinue in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 12-10-2008, 05:26 PM
  2. is there a weird rule about symbolic constants?
    By i_can_do_this in forum C Programming
    Replies: 5
    Last Post: 07-10-2006, 07:14 AM
  3. Symbolic debugging
    By lyx in forum Windows Programming
    Replies: 1
    Last Post: 12-03-2003, 03:16 PM
  4. Help with Constants and enum constants. Newbie learning C++.
    By UnregJDiPerla in forum C++ Programming
    Replies: 5
    Last Post: 01-07-2003, 08:29 PM
  5. Symbolic Constants??
    By ACAC in forum C++ Programming
    Replies: 1
    Last Post: 09-29-2001, 06:09 PM