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

C program to multiply two floating point numbers?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-09-14 15:53:04
forward
1214 people have browsed it

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;
}
Copy after login
Output
75.241
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template