Answers for "how to round to one decimal point in c"

C
2

rounding decimal number in C

#include <stdio.h>
#include <math.h>
 int main()
{
       float i=5.4, j=5.6;
       printf("round of  %f is  %f\n", i, round(i));
       printf("round of  %f is  %f\n", j, round(j));
       return 0;
}
Posted by: Guest on July-30-2021
0

Rounding Floating Point Number To two Decimal Places in C

#include <iostream>
using namespace std;
int main()
{
    float var = 37.66666;
 
    // Directly print the number with .2f precision
    printf("%.2f", var);
    return 0;
}
Posted by: Guest on March-05-2022

Code answers related to "how to round to one decimal point in c"

Code answers related to "C"

Browse Popular Code Answers by Language