Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language topic: The following correct real constants are () A, E3.4 B, -12345 C, 2.2e.8 D, 4. Why is D wrong?
C language topic: The following correct real constants are () A, E3.4 B, -12345 C, 2.2e.8 D, 4. Why is D wrong?
D is an integer constant, not a real type. The sign of a real type is in the form of decimal point and exponent. Even if its value is equal to an integer, it should be written in the form of decimal point or exponent.

real constants are also called real numbers or floating-point numbers. A real constant can be expressed in two forms in C language.

I. Decimal form

Decimal form is a real number representation form consisting of numbers and decimal points. For example, .123, .123, 123. and . are all legal real constants.

note: real constants expressed in decimal form must have decimal points.

Second, the exponential form

This form is similar to the exponential form in mathematics. In mathematics, one can be expressed as a power, for example, 2.326 can be expressed as .2326× 112.326× 123.26× 1-1. In C language, "e" or "e" is followed by an integer to represent the power number with "1" as the base. 2.326 can be expressed as .2326E1, 2.326e and 23.26e-1. According to the grammar of C language, there must be a number before the letter E or E, and the exponent after E or E must be an integer. Such as e3, 5e3.6,. E, E, etc. are all illegal exponential forms. Note: Do not insert spaces before and after the letter E or E or between numbers. In the process of running a program, the quantity whose value cannot be changed is called a constant. There are different types of constants, among which 12, and -5 are integer constants. A''b' is a character constant. While 4.6 and -8.7 are real constants.

a real constant can be assigned to a float, double or long double variable. According to the type of the variable, the corresponding significant digits in the real constant are intercepted.