Question 9
Back to Exercise
What is the difference between abs() and fabs()?
- A No difference
- B abs takes an int (stdlib.h); fabs takes a double (math.h) Correct
- C fabs is faster
- D abs works only on positive numbers
Correct Answer: Option B
abs(-2.7) converts the argument to int and returns 2. Use fabs for floating values, labs/llabs for long types.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!