#include <iostream> #include <iomanip> #include <iostream> int main() { double d = 122.345; cout << fixed << setprecision(2) << d; //the setprecision can vary as per required }