Home  >  Article  >  Backend Development  >  C program to multiply two floating point numbers?

C program to multiply two floating point numbers?

WBOY
WBOYforward
2023-09-14 15:53:041003browse

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.

Floating point number

##Floating point numberfloat4 bytes 4 bytes double8 bytes8 byteslong double8 bytes8, 12 or 16 bytes
Category

Type

Minimum Size

Typical size

Floating point range

SizeRangePrecision# #4 bytes to ±3.4 x 108 bytes 3084932±3.36 x 10Input

##±1.18 x 10

-38

386-9 significant digits, usually 7

##±2.23 x 10 -308

to ±1.80 x 10

15-18 significant digits, usually 16

80 bits (usually 12 or 16 bytes are used)

±3.36 x 10-4932

to ±1.18 x 10

#18-21 valid digits

16 bytes

-4932 to ±1.18 x 10

4932

33-36 valid Number

Example

− a=11.23 b=6.7

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete