![]() |
The fdim() function in C is part of the standard math library <math.h> and is used to compute the positive difference between two floating-point numbers. This function is particularly useful when we need to determine the non-negative difference between two given values. It returns the difference between two values if the first value is greater than the second; otherwise, it returns zero. Syntax of fdim() in Cdouble fdim(double x, double y); Parameters of fdim() in CThe fdim() function in C takes the following parameters:
Return Value of fdim() in CThe fdim() function returns the positive difference between x and y. If x is greater than y, it returns x – y; otherwise, it returns 0. Examples of fdim() Function in CThe below examples demonstrate how we can use the fdim() function in C language. Input: Example 1The below program demonstrates how to calculate the positive difference between two given numbers using the fdim() function in C.
Output The positive difference between 5.50 and 3.20 is: 2.30 Time Complexity: O(1) Example 2The following program demonstrates how to compute the positive difference for different data types in C.
Output The positive difference between 5.50 and 3.20 is: 2.30 The positive difference between 6.50 and 3.20 is: 3.30 The positive difference between 7.50 and 3.20 is: 4.30 Time Complexity: O(1)
|
Reffered: https://www.geeksforgeeks.org
C Language |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 17 |