- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
fabs() in C++
The C or C++ library function double fabs(double x) returns the absolute value of x. x − This is the floating point value. This function returns the absolute value of x. Following is the declaration for fabs() function.
double fabs(double x)
The following example shows the usage of fabs() function.
Example
#include <iostream> #include <cmath> using namespace std; int main () { int a, b; a = 1234; b = -344; cout << "The absolute value of " << a << " is " << fabs(a) << endl; cout << "The absolute value of " << b << " is " << fabs(b) << endl; return(0); }
Output
The absolute value of 1234 is 1234 The absolute value of -344 is 344
Advertisements