C - Write program to output array element value using point

Requirements

Write program to output array element value using point

Demo

#include <stdio.h>

int main()//  w  w  w .java 2s . com
{
    int numbers[10];
    int x;
    int *pn;

    pn = numbers;       /* initialize pointer */

/* Fill array */
    for(x=0;x<10;x++)
    {
        *pn=x+1;
        pn++;
    }

    pn = numbers;

/* Display array */
    for(x=0;x<10;x++)
    {
        printf("numbers[%d] = %d, address %p\n",
                x+1,*pn,pn);
        pn++;
    }

    return(0);
}

Result

Related Exercise