Header file:
math.h
Synopsis:
double modf(double x, double *iptr);
Description:
It splits the value x into integral and fractional parts. Returns fractional part and stores the integral part in iptr.
modf function C example:
#include<stdio.h>
#include<math.h>
int main() {
double x, res, ip;
printf("Enter the value for x:");
scanf("%lf", &x);
res = modf(x, &ip);
printf("Integral part: %d\tFraction:%lf\n", (int)ip, res);
printf("x:%lf\n", x);
return 0;
}
#include<math.h>
int main() {
double x, res, ip;
printf("Enter the value for x:");
scanf("%lf", &x);
res = modf(x, &ip);
printf("Integral part: %d\tFraction:%lf\n", (int)ip, res);
printf("x:%lf\n", x);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/math$ ./a.out
Enter the value for x:56.56
Integral part: 56 Fraction:0.560000
x:56.560000
Enter the value for x:56.56
Integral part: 56 Fraction:0.560000
x:56.560000
Do you need Finance? Are you looking for Finance? Are you looking for finance to enlarge your business? We help individuals and companies to obtain finance for business expanding and to setup a new business ranging any amount. Get finance at affordable interest rate of 3%, Do you need this finance for business and to clear your bills? Then send us an email now for more information contact us now via (financialserviceoffer876@gmail.com) whats-App +918929509036 Dr James Eric Finance Pvt Ltd Thanks
ReplyDelete