Answers for "std cout 2 digits float"

C++
8

std cout 2 digits float

#include <iostream>
#include <iomanip>

int main()
{
    double d = 122.345;

    std::cout << std::fixed;
    std::cout << std::setprecision(2);
    std::cout << d;
}
Posted by: Guest on May-19-2020

Browse Popular Code Answers by Language