Home > Article > Backend Development > C program to multiply two floating point numbers?
Float is the abbreviation of "floating point number". By definition, it is a compiler-built-in basic data type used to define numerical values with floating decimal points. Floating-point type variables are variables that can hold real numbers, such as 4320.0, -3.33, or 0.01226. The floating-point part of the name refers to the fact that the decimal point can "float", that is, it can support a variable number of numbers before and after the decimal point.
Category | Type | Minimum Size | Typical size |
---|---|---|---|
| float4 bytes | 4 bytes | |
double | 8 bytes | 8 bytes | |
long double | 8 bytes | 8, 12 or 16 bytes |
Range | Precision | |
---|---|---|
##±1.18 x 10 -38 | to ±3.4 x 10386-9 significant digits, usually 7 | 8 bytes |
##±2.23 x 10 -308 to ±1.80 x 10 | 30815-18 significant digits, usually 16 | 80 bits (usually 12 or 16 bytes are used) |
±3.36 x 10-4932 to ±1.18 x 10 | 4932#18-21 valid digits | 16 bytes
|
-4932 to ±1.18 x 10 4932 |
33-36 valid Number | Example |
Output − 75.241
Explanation − Use floating point variables. In this program, the user has two numbers (floating point numbers), i.e. floating point variables. The product of these two numbers is then stored in a variable and displayed on the screen.
Example#include <stdio.h> int main() { float a, b, c; a=11.23; b=6.7; c = (float)(a*b); // Displaying result up to 3 decimal places. printf("%3f", c); return 0; }Output
75.241
The above is the detailed content of C program to multiply two floating point numbers?. For more information, please follow other related articles on the PHP Chinese website!