Answers for "c++ how to make double two decimal places"

C++
1

how print fload wiht 2 decimal in c++

#include <iostream>
#include <cstdio>
using namespace std;

int main() 
{
    // This code helps you to print a number with desired decimal
    double Number=10.3454;
    printf("%.3lf",Number);

    return 0;
}
Posted by: Guest on June-07-2020
0

round double to 2 decimal places c++

double d = 0.12345;
std::cout.precision(2); // for accuracy to 2 decimal places 
std::cout << d << std::endl; // 0.12
Posted by: Guest on September-13-2020

Code answers related to "c++ how to make double two decimal places"

Browse Popular Code Answers by Language