﻿

# modf() function of math.h in C

﻿

In this article, we are going to learn about the use modf() function of math.h header file and use it with the help of an example.
Submitted by Manu Jemini, on April 01, 2018

This function solves some of the basic problems of mathematics, which will be much complex in programming.

The modf() function takes two parameters, first is the floating point value which needs to be processed and second the address of an integer.

The Function returns the fractional values if the first parameter and stores the remaining whole number in the integer which has been passed to the function.

Example:

```    X = 10.858
Function will return 0.858
Function will store the value in the integer = 10
```

The Function is a part of the math.h library which should be included in the program before using this function.

﻿

## math.h - modf() function Example in C

```#include <stdio.h>
#include <math.h>

int main()
{
// Defining variables
double a,b,c;

// Assigning value for getting modf value
a = 54.545;

// Calculating floating-point value into
//an integer and a fractional part
c = modf(a, &b);

// Displaying the result for the user
printf("The calculated value is: %lf \n\n", c);

return 0;
}
```

Output

﻿

﻿

﻿
﻿

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com (2015-2018), Some rights reserved.