scanf - Input decimal numbers in C -


this question has answer here:

i extremely beginner in programming language. facing problems. please me out. possible take input floating or double number 2 digits after decimal point using 'scanf' in c ??

thanks in advance.

see here: how accept precision (so many decimals places) in scanf?

float value; scanf("%4f", &value); 

it's not that, reads 4 digit edit: 4 characters float number. can set other number instead of 4.

if need 2 decimal places can read number scanf, , after round using roundf.

#include <math.h> ... float value; scanf("%f", &value); value = roundf(value*100)/100 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -