Page 25 - PROGRAMMING IN C_Neat
P. 25

Memory Storage:
                                                 a         Variable Name

                                                 6         Value

                                               1001        Variable Address

                                                 p         Pointer Variable Name

                                              1001         Value

                                               2001        Pointer Variable Address
         Accessing Variable through Pointer Variable:
                              *p
           *p – content of pointer variable, p.

                              Memory Storage:
                                                 a         Variable Name

                                                 6         Value

                                               1001        Variable Address
                                        *p
                                                 p         Pointer Variable Name

                                              1001         Value

                                               2001        Pointer Variable Address

           Value of a is 6. Value of  *p is also 6.
        _______________________________________________________________________________________

        2. What are the advantages of pointers? ***

        Advantages of Pointers:
         Increase the program execution speed.
         Reduce the program length and complexity.
         Used to send data inside and outside a function.
        _______________________________________________________________________________________

        3. Explain pointers and one dimensional array. ***

        Pointers and One Dimensional Array:
         a[0] is the first element of the one dimensional array, a. The address of a[0] is assigned to pointer variable,
          p.
                              p = &a[0];

         p+1 gives the address of a[1].
          p+2 gives the address of a[2].
                       .
                       .
                       .
          p+n gives the address of a[n].
   20   21   22   23   24   25   26   27   28