modf() c++

Asked  May 24, 04:35 am 28 Views Add Your Answer
Asked  May 24, 04:35 am
C++
0 Dislikes
0 Comments

1 Answers

Added  May 27, 07:53 am

#include <iostream>
#include <cmath> 
#include <iomanip> 
using namespace std;
#define prec cout<<fixed<<setprecision(8);
int main ()
{
  double param, fractpart, intpart;
  prec
  param = 3.14159265;
  fractpart = modf (param , &intpart); // Break into fractional and integral parts (function )
  cout<< param<<" = ("<<intpart<<" + "<<fractpart<<")"; // 3.14159265 = (3.00000000 + 0.14159265)
}

0 Likes 0 Dislikes
0 Comments
×
Google login
SignUp with Email
X