Pointer Handle Array Values in C


Use a pointer to an array, and then use that pointer to access the array elements.

Source Code

#include<stdio.h>
int main()
{
    int a[]={10,20,30,40,50};
    int *p;
    //{10,      20,     30,     40,     50}
    //{6356712,6356716,6356720,6356724,6356728}
    p=&a;
 
 
    printf("\nSize of integer    : %d",sizeof(int)); //4
    printf("\nSize of a          : %d",sizeof(a));  //20
    printf("\nLength of a        : %d",sizeof(a)/sizeof(int));//5
    printf("\nAddress of A       : %d",&a);//6356712
    printf("\nValue  of P        : %d",p);//6356712
 
    p++;
    printf("\nValue  of P        : %d",p);//6356716
    printf("\nValue  of *P       : %d",*p);//20
 
    printf("\nValue  of *++P        : %d",*++p);//30
    printf("\nValue  of ++*P        : %d",++*p);//31
 
    return 0;
}
 
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes