Home » C programs » math.h header file functions

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.

#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**

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions

.resCodeAS1 { display: block; width: 320px; height: 50px; }
@media(min-width: 300px) { .resCodeAS1 { display: none; } }
@media(min-width: 480px) { .resCodeAS1 { display: none; } }
@media(min-width: 750px) { .resCodeAS1 { display: block; width: 336px; height: 280px; } }
(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});

(adsbygoogle = window.adsbygoogle || []).push({});

solved programs: » C » C++ » DS » Java » C# |

aptitude que. & ans.: » C » C++ » Java » DBMS |

interview que. & ans.: » C » Embedded C » Java » SEO » HR |

close Like other websites, this site uses cookies to deliver relevant ads based on your interest, by using our website, you acknowledge that you have read our privacy policy.