How To Get Precision To Two Decimal Places In C

[Solved] How To Get Precision To Two Decimal Places In C | Perl - Code Explorer | yomemimo.com
Question : How to get precision to two decimal places in c

Answered by : nishit-dua

#include <iostream>
using namespace std;
int main()
{
    float var = 37.66666;
 
    // Directly print the number with .2f precision
    printf("%.2f", var);
    return 0;
}

Source : https://www.geeksforgeeks.org/rounding-floating-point-number-two-decimal-places-c-c/ | Last Update : Sat, 12 Mar 22

Answers related to how to get precision to two decimal places in c

Code Explorer Popular Question For Perl