<<< Text segment     Index     Uninitialized data segment >>>

9. Data segment


    program in computer memory
  • Initialized data segment (or simply the data segment), contains variables that

    • (a) are specifically initialized in the program.

    • (b) declared outside any function

  • For example,

  • 
        #include <iostream>
        double Pi = 3.1415926;
        int main()
        {
          std::cout << "Pi equals " << Pi << '\n';
          return 0;
        }
    
    

    Variables declared outside any function are called global variables.

    Pi demonstrates an initialized global variable.


<<< Text segment     Index     Uninitialized data segment >>>