Float Keyword


In C programming, the 'float' keyword is used to declare variables that hold single-precision floating-point numbers.

Single-precision means that these variables can store decimal values with a certain level of precision and range.

Here's an example of using the 'float' keyword to declare a variable:


float pi = 3.14159;

    

In this example, the 'float' keyword is used to declare a variable named 'pi' and initialize it with the value 3.14159.

Floating-point variables are typically used to represent real numbers, such as measurements or calculations involving decimal values.

It's worth noting that in C, floating-point literals without a suffix are treated as 'double' by default.

To explicitly specify a 'float' literal, you can append the 'f' or 'F' suffix to the value.

Loading...

Search