-->

Program to know array as pointer

using codeblocks
----------------------------------------------------------------------------------------------------------
//understanding array as pointer      //comment of program
#include <stdio.h>                     //header file
int main()
{
    int a[]={2,3,4,5,6};                 //array with some values
    int i;
    int *p;
    p=a;                               //assigns base address to pointer
    printf("the address of array=%d\n",p);//prints address of array
    p=&a[0];                            //assigns address of zeroth element
    printf("the address of array=%d\n",p);//prints address of zeroth element
    return 0;
}

//note:- In both cases, we get same address.
//Because computer takes address of array same  as of address of zeroth element.
//So , this array acts as pointer

/*If we want to display all addresses of all elements of an array, then
we write ;click below

https://practisingprograms.blogspot.com/2019/01/program-to-understand-array-as-pointer_12.html


*/

1 comment:

  1. Thanks for Sharing...Keep Update…

    Web Hosting is the process of buying space for a website on the World Wide Web.

    What is Web Hosting
    Web Hosting for Beginners

    ReplyDelete