 Home >>C Math Functions >C math modf() function

# C math modf() function

### C math modf() function

C math modf() function is used to return the fraction component (part after the decimal) and set integer to the integer component. It takes two different arguments and return a value with same sign.

Syntax:
`double modf(double x, double *integer)`

### Parameter Values

Parameter Description
x It is the floating point value.
integer It is the pointer to an object where the integral part is to be stored.
Here is an example of modf() function:
``````
#include <stdio.h>
#include <math.h>
int main ()
{
double x, fractpart, intpart;
x = 8.123;
fractpart = modf(x, &intpart);
printf("Integral part = %lf\n", intpart);
printf("Fraction Part = %lf \n", fractpart);
return(0);
}
```
```
Output:
Integral part = 8.000000
Fraction Part = 0.123000
Example-2
``````
#include <stdio.h>
#include <math.h>
int main ()
{
double x, fractpart, intpart;
x = 340.1283;
fractpart = modf(x, &intpart);
printf("Integral part = %lf\n", intpart);
printf("Fraction Part = %lf \n", fractpart);
return(0);
}
```
```
Output:
Integral part = 340.000000
Fraction Part = 0.128300