Answers for "print 2 digits after decimal inc"

C++
1

how to print numbers with only 2 digits after decimal point in c++

#include <iostream>
#include <iomanip>
#include <iostream>
​
int main()
{
	double d = 122.345;
	cout << fixed << setprecision(2) << d;
  	//the setprecision can vary as per required
}
Posted by: Guest on August-29-2021

Code answers related to "print 2 digits after decimal inc"

Browse Popular Code Answers by Language