C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math abs()The function finds the absolute value of a given number. Suppose a number is 'x': abs(x) = |x|; Difference between abs() and fabs()The abs() function does not support float or double type arguments while fabs() function supports float, double as well as integer type arguments. Syntaxint abs( int x); long int abs(long int x ); long long int abs(long long int x); Parameterx: The value whose absolute value is to be determined. Return valueIt returns the absolute value of x. Example 1Let's see the simple example when the value of x is negative. #include Output: Value of x is :-9 Absolute value of x is : 9 In this example, abs() function computes the absolute value of x and returns the value 9. Example 2Let's see the simple example when the value of x is positive. #include Output: Value of x is :89 Absolute value of x is : 89 In this example, abs() function computes the absolute value of x.
Next TopicC++ Math Functions
|