Answers for "math decimal 2 places c++"

C++
2

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;
}
Posted by: Guest on January-01-2022
0

round double to 2 decimal places c++

double d; 
	std::cout.precision(3); // for accurancy to 3 decimal places
	std::cout << d << std::endl;
Posted by: Guest on October-23-2021
0

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";
Posted by: Guest on April-03-2021

Code answers related to "math decimal 2 places c++"

Browse Popular Code Answers by Language