I am trying to write a prog that will allow input of float values and calculate profits from these values.I need to be able to print out a minus sign if the profits are negative and the '-' has to be on the right hand side of the output value.I have worked out that you can print a minus on the right by using %5.2f- but I need to test the value stored in the variable.
Is there an easy way to tell if the value stored in the variable is negative so I can use this format specifier .
What I'd like to do is use the ternary operator e.g.
(value<0) ? %5.2f- : %5.2f ; but this doesn't work
Any ideas gents?(or ladies(College Girl))