c / beginner
Snippet
Floating Point Datatypes
C uses 'float' and 'double' to store numbers with decimal points. 'double' provides more precision than 'float'.
snippet.c
1
2
float weight = 72.5f;double distance = 1250.456;
Breakdown
1
float weight = 72.5f;
Declares a single-precision decimal variable. The 'f' suffix denotes a float literal.
2
double distance = 1250.456;
Declares a double-precision variable, which is the standard for decimals in C.