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