Cnth February 2016
Input decimal numbers in C
I am extremely beginner in programming language. so i am facing some problems. please help me out.
Is it possible to take input a floating or double number with 2 digits after the decimal point using 'scanf' in C ??
Thanks in advance.
Dubon February 2016
How to only accept a certain precision (so many decimals places) in scanf?
It's not really do that, but reads 4 digit
edit: 4 characters float number. You can set other number instead of 4.
If you really need only 2 decimal places you can read the number with
scanf, and after that round it using
value = roundf(value*100)/100
Spencer February 2016
You can read floats with
You can read doubles with
Asked in February 2016
Viewed 3,663 times Voted 5 Answered 2 times
Leave an answer
Quote of the day: live life
Devs Planet © all rights reserved