Page 23 - PROGRAMMING IN C_Neat
P. 23

There are four storage classes:
        1. Automatic Variables:
           These variables are declared inside a function.
           General Form:

                        auto  datatype  variablename;

           Example:
               main()
               {
                       auto  int  a;
                       _  _  _
                       _  _  _
                       _  _  _
               }

        2. External Variables:
           These variables are declared outside all the functions.
           They are common to all the functions.
           Example:
               int  a;

               main()
               {
                       _  _  _
                       _  _  _
                       _  _  _
               }

               void  xyz()
               {
                       _  _  _
                       _  _  _
                       _  _  _
               }

        3. Static Variables:
           These variables retain their values until the end of the program.
           General Form:

                        static  datatype  variablename;

           Example:
               static  int  a;

        4. Register Variables:
           These variables are stored in the CPU registers.

           General Form:

                        register  datatype  variablename;

           Example:
               register  int  a;
        _______________________________________________________________________________________
   18   19   20   21   22   23   24   25   26   27   28