how to get 4 decimal places in c++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double d = 122.345;
cout << fixed << setprecision(4) << d;
}
how to get 4 decimal places in c++
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double d = 122.345;
cout << fixed << setprecision(4) << d;
}
round double to 2 decimal places c++
double d;
std::cout.precision(3); // for accurancy to 3 decimal places
std::cout << d << std::endl;
get number round off to two decimal places c++
float a,b,c,d,sum;
cin>>a>>b>>c>>d; // reading decimal values
sum=(a*b*c*d);
sum=round(sum*100)/100; // here it is for 2 decimal points
if((float)sum < (float) 9.58)
cout<<"YES\n";
else
cout<<"NO\n";
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us