Float Notation
In C programming, we can use the letters f
or F
at the end of a floating-point number to signify that it's a float
. For example,
#include <stdio.h> int main() { // use float notation float number = 36.43f; // print the variable printf("%f", number); return 0; } // Output: 36.430000
Notice that we've used 36.43f
instead of just 36.43
. This indicates that the number is of float
type.
Alternatively, we can also use F
to indicate that it's a float
:
float number = 36.43F;
f
or F
to indicate a float
value. However, it's a good practice and we recommend it. But we won't be using this notation frequently in this course for the sake of simplicity..