English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The functionmodf()
used to split the passed parameter into integer and decimal. Declare the variable in the 'math.h' header file for mathematical calculations. It returns the fractional value of the passed parameter.
This ismodf()
C Language Syntax
double modf(double value, double *integral_pointer);
Here,
Value-value divided into integer and fraction.
Integral Pointer-points to the integer part after the split.
This ismodf()
C Language Example
#include<stdio.h> #include<math.h> int main () { double val, x, res; val = 28.856; res = modf(val, &x); printf("Integral part of val: %lf\n", x); printf("Fraction Part of val: %lf \n", res); return(0); }
Output Result
Integral part of val: 28.000000 Fraction Part of val: 0.856000
In the above program, the functionmodf()
Divides a floating-point number into its integer and fractional parts. Declare three variables as val, x, and res. The variable res stores the value calculated by the computationmodf()
.
res = modf(val, &x);