Real or Floating-point constant

Constants in C are fixed value that does not change during the execution of a program. A real constant is combination of a

Use of Real or Floating-point constants

Integer numbers are inadequate to represent quantities that vary continuously, such as distances, heights, temperatures, prices and so on. These quantities are represented by numbers containing fractional part. Such numbers are called

The Real or Floating-point constants can be written in

Express a Real constant in fractional form

A real constant consists for a series of digits representing the whole part of the number, followed by a decimal point, followed by a series of representing the fractional part. The whole part or the fractional part can be omitted, but both cannot be omitted. The decimal cannot be omitted. That is, it is possible that the number may not have digits before the decimal point or after the decimal point.

1, 2.3 - Illegal character (.)

1. A real constant must have at least one digit.

2. It must have a decimal point.

3. It could be either positive or negative.

4. Default sign is positive.

5. Commas or blanks are not allowed within a real constant.

Express a real constant in Exponential form

A real constant is combination of a

In exponential form, the real constant is represented in

7500000000 can be represented in exponential form as 7.5e9 or 75E8

1. The mantissa part and the exponential part should be separated by letter in exponential form

2. The mantissa part may have a positive or negative sign.

3. Default sign of mantissa part is positive.

4. The exponent part must have at least one digit, which must be a positive or negative integer. Default sign is positive.

5. Range of real constants expressed in exponential for is -3.4e38 to 3.4e38.

Questions

Part-A

Part-B

Constants in C are fixed value that does not change during the execution of a program. A real constant is combination of a

**whole number**followed by a**decimal point**and the**fractional part**.**Example**: 0.0083 -0.75**.**95 215**.**Use of Real or Floating-point constants

Integer numbers are inadequate to represent quantities that vary continuously, such as distances, heights, temperatures, prices and so on. These quantities are represented by numbers containing fractional part. Such numbers are called

**real**or**floating point**constants.The Real or Floating-point constants can be written in

**two**forms:**1.****Fractional**or**Normal**form**2.****Exponential or Scientific**formExpress a Real constant in fractional form

A real constant consists for a series of digits representing the whole part of the number, followed by a decimal point, followed by a series of representing the fractional part. The whole part or the fractional part can be omitted, but both cannot be omitted. The decimal cannot be omitted. That is, it is possible that the number may not have digits before the decimal point or after the decimal point.

**Valid**Real constants (Fractional): 0.0 -0.1 +123.456 .2 2.**Invalid**Real constant: - 1 - a decimal point is missing1, 2.3 - Illegal character (.)

**Rules for Constructing**Real**Constants in**Fractional**Form**1. A real constant must have at least one digit.

2. It must have a decimal point.

3. It could be either positive or negative.

4. Default sign is positive.

5. Commas or blanks are not allowed within a real constant.

Express a real constant in Exponential form

A real constant is combination of a

**whole number**followed by a**decimal point**and the**fractional part**. If the value of a constant is either too small or too large, exponential form of representation of real constants is usually used.In exponential form, the real constant is represented in

**two**parts.**Mantissa**- The part appearing before**e,**the mantissa is either a real number expressed in decimal notation or an integer.**Exponent**- The part following**e,**the exponent is an integer with an optional plus or minus sign followed by a series of digits. The letter e separating the mantissa and the exponent can be written in either lowercase or uppercase.**Example:**0.000342 can be represented in exponential form as 3.42e-47500000000 can be represented in exponential form as 7.5e9 or 75E8

**Rules for Constructing**Real**Constants in**Exponential**Form**1. The mantissa part and the exponential part should be separated by letter in exponential form

2. The mantissa part may have a positive or negative sign.

3. Default sign of mantissa part is positive.

4. The exponent part must have at least one digit, which must be a positive or negative integer. Default sign is positive.

5. Range of real constants expressed in exponential for is -3.4e38 to 3.4e38.

Questions

Part-A

- What is a real or floating-point constant?
- What is the use of real or floating-point constants?
- What are different forms of real constants?
- How do you express a real constant in fractional form? Give example.
- State the rules for constructing real constants in Fractional form.
- How do you express a real constant in Exponential form? Give example.
- State the rules for constructing real constants in Exponential form

Part-B

- Write short notes on: real (Or) floating-point constants
- Explain about real constants with examples?