Q7. Construct an expression that is equal to the absolute value of a variable. That is, if a variable p is positive, the value of the expression is just p, but if p is negative, the value of the expression is –p. which would be positive. Do it in two ways:
- using a mathematical function
- using a conditional operator. (Do not use the mathematical function here).
Ans.(2). p > 0 ? p : -p