Rounding Number to 2 Decimal Places in C?
How can I round a float (such as 37.777779) to two decimal places (37.78) in C?
Patrick B.
answered 06/26/19
Math and computer tutor/teacher
#include <stdio.h>
#include <math.h>
int main()
{
double x=37 + 7.0f/9;
x = round ( x*100)/100;
printf("%8.2lf \n",x);
}
Still looking for help? Get the right answer, fast.
OR
Find an Online Tutor Now
Choose an expert and meet online.
No packages or subscriptions, pay only for the time you need.