The fdim() function takes two arguments and returns the positive difference between first and second argument.
This function returns a-b if a>b otherwise returns 0. where, a is the first argument and b
is the second argument.
double fdim(double a, double b); float fdim(float a, float b);
The fdim() function takes two arguments a and b, where, a is the first argument and b is the second argument.
This function returns a-b if a>b otherwise returns 0.
It is mandatory to give both the arguments otherwise it will give error no matching function for call to 'fdim()' like this.
Inuput : fdim(2.0, 1.0) Output : 1 Inuput : fdim(-2.0, 1.0) Output : 0
# CODE 1
fdim of (2.0, 1.0) is 1 fdim of (1.0, 2.0) is 0 fdim of (-2.0, -1.0) is 0 fdim of (-1.0, -2.0) is 1
# CODE 2
fdim of (5.0, 4.0) is 1 fdim of (4.0, 5.0) is 0 fdim of (-5.0, -4.0) is 0 fdim of (-4.0, -5.0) is 1
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- How to Learn Python in 21 Days?
- How to iterate over the elements of an std::tuple in C++
- Top Programming Languages for Data Science in 2020
- How to access private/protected method outside a class in C++
- Top 5 Most Loved Programming Languages in 2020
- lvalues references and rvalues references in C++ with Examples
- Difference between cout and std::cout in C++
- What happens when we call a Function
- C++ program to check whether a String is a Pangram or not
- Matrix operations using operator overloading
- Difference between pair in Multiset and Multimap in C++ STL
- How to use unordered_map efficiently in C++
- Header files in C/C++ with Examples
- How to take input in Octave GNU?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.