round double to n decimal places c++
value = round( value * 100.0 ) / 100.0; // 2 decimal places
value = round( value * 1000.0 ) / 1000.0; // 3 decimal places
round double to n decimal places c++
value = round( value * 100.0 ) / 100.0; // 2 decimal places
value = round( value * 1000.0 ) / 1000.0; // 3 decimal places
round double to 2 decimal places c++
double d = 0.12345;
std::cout.precision(2); // for accuracy to 2 decimal places
std::cout << d << std::endl; // 0.12
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