Pay attention to the function round in cpp code example Example: nearest integer rounding in c++ cout << "Nearest value of x :" << round(x) << "\n";