|
|
|||||
|
Get the Ebook
C Tutorial
Source Code
Function Reference
|
modf()Prototype: double modf(double number, double *intpart);Header File: math.h (C) or cmath (C++) Explanation: This function will return the decimal part of number, and it will place the integer part of number into the variable pointed to by intpart. Example:
//Example will output decimal and integer parts of 12.34
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
double x;
modf(12.34, &x);
cout<<"Decimal: "<<modf(12.34, &x)<<"Fractional: "<<x;
}
Other Functions
Want to become a C++ programmer? The Cprogramming.com ebook, Jumping into C++, will walk you through it, step-by-step. Get Jumping into C++ today!
Popular pages
Custom Search
|
||||