Printig data for a perticular decimal range

How can i print a double or float data type for particular decimal points(like 3 decimal point is .333 .122 etc) using cout?Can anyone help please?
Use std::fixed:
http://en.cppreference.com/w/cpp/io/manip/fixed
http://en.cppreference.com/w/cpp/io/manip/setprecision
1
2
3
4
5
6
7
8
9
#include <iomanip>
#include <iostream>

int main()
{
	double d = 1.23456789;
	std::cout << d << '\n';
	std::cout << std::fixed << std::setprecision(3) << d << '\n';
}
http://coliru.stacked-crooked.com/a/a29b25af4a36b0b5
Thank you.It works.
Topic archived. No new replies allowed.