-   Programming (
-   -   printing negative value as positive (

hubabuba 05-02-2005 04:21 PM

printing negative value as positive

I can't get this right.
A result of a subtraction of one int variable with positive value from another int variabe with positive value, produces a negative value and stores it in the third int value. How can i print the negative value as positve (without the minus sign)?


ahwkong 05-02-2005 04:46 PM

what language?

If the language provide abs() (absolute value), you can apply this to the neg num before printing.

hubabuba 05-02-2005 05:54 PM

C Language.

I'm a begginer, I don't know if it provides abs() .

ahwkong 05-02-2005 07:45 PM

Being beginner is no excuse for not looking it up yourself.

Using google and keyword "abs c" I found some reference right away.

itsme86 05-03-2005 10:45 AM

Just check if the number is negative. If it is then multiply it by -1.

hubabuba 05-03-2005 12:41 PM

Thanks for your replies. Worked out how to use the abs().

All times are GMT -5. The time now is 09:13 PM.