I have this
double a = 4.0; double b = 2.0; double g = a + b; std::cout << g;
I am getting 6, but I want to get 6.0>
6
6.0>
If you always want one figure after the decimal point regardless of how many digits the answer is, use std::fixed along with std::setprecision
std::fixed
std::setprecision
#include std::cout << std::fixed << std::setprecision(1) << g;