Hey can someone help explain how to use the rounding function.
I want to round to the 2nd digit in a float. Such as 1.85458 to 1.85. How would i go about doing this. I currently keep rounding to the closest integer so the above would round to 2. Thank you in advance for your help!
Code:#include <stdio.h> #include <math.h> int main(void) { float n; do { printf("input a floated number to 7th decimal: "); n = ask for integer; } while (n != 0); n = roundf(n); printf("%.7f\n", n); }