abs(): This function finds the absolute value of the given number. If the number
is positive then the same number is returned. Otherwise, the negation of that
number is returned.
This function is available in the below file.
File: stdlib.h
Parameters: One parameter is required for this function.
__X: Value whose absolute value to be fined.
Syntax:
abs(__X)
For Example:
1. abs(10) = > Since , x is positive so same x is returned (i.e 10)
2. abs(-10) => x is negative, so negation of that number is returned (i.e. 10)
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){int x = -10;cout << abs(x) << "\n";return 0;}
No comments:
Post a Comment