C Programming Language
  • Home
  • C Fundamentals
    • C Character Set
    • Tokens >
      • Keywords
      • Identifiers
      • Constants >
        • Definition and Its types
        • Numeric Constants >
          • Integer Constants
          • Real Constants
        • Character Constants
        • String Constants
        • Backslash Character
      • Operators >
        • Definition and Its types
        • Arithmetic
        • Relational
        • Logical
        • Increment
        • Decrement
        • Assignment
        • Arithmetic Assignment
        • Conditional
        • Bitwise
        • Special Operators
        • Hierarchy
    • Data Types >
      • Primary (Or) Basic
      • User-Defined
      • Derived
    • Variable >
      • Definition
      • Declaration
      • Initialization
  • Control Structures
    • Decision-Control >
      • If Statement >
        • Simple-if Statement
        • if-else Statement
        • Nested-if Statement
        • if-else ladder Statement
      • Switch Statement
    • Loop Control >
      • For
      • While
      • Do-While
  • Arrays
    • Introduction
    • Single-Dimensional >
      • Definition
      • Declaration
      • Initialization
    • Two-Dimensional >
      • Definition
      • Declaration
      • Initialization
    • Multi-Dimensional >
      • Definition
      • Declaration
      • Initialization
  • Functions
    • Definition
    • Standard Library Character Functions
    • Standard Library String Functions
    • Storage Classes >
      • Definition
      • Automatic
      • Register
      • Static
      • External
  • Pointers
  • Files
    • Concepts
    • Data Files and its Categories
    • Standard Files and its Categories
  • University Questions
    • April 2001 To 2005
    • April 2006 To 2010
    • April 2011 To 2015
    • November 2001 To 2005
    • November 2006 To 2010
    • November 2011 To 2015

 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 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 form

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.         

Valid Real constants (Fractional): 0.0      -0.1     +123.456       .2         2.
Invalid Real constant: -                  1              -           a decimal point is missing
                                                            1, 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-4
                                          7500000000 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
  1. What is a real or floating-point constant?
  2. What is the use of real or floating-point constants?
  3. What are different forms of real constants?
  4. How do you express a real constant in fractional form? Give example.
  5. State the rules for constructing real constants in Fractional form. 
  6. How do you express a real constant in Exponential form? Give example.
  7. State the rules for constructing real constants in Exponential form

Part-B
  1. Write short notes on: real (Or) floating-point constants
  2. Explain about real constants with examples?

Powered by Create your own unique website with customizable templates.