how can i access the element of 1D array by using pointer

 Code:-

#include<stdio.h>
#include<stdlib.h>
int main()
{
int a[10],*p,i;
printf(“Enter the 10 element of the arrayn”);
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
p=&a[0];
printf(“The element of the array is:-n”);
for(i=0;i<10;i++)
printf(“%d “,*(p+i));
return 0;
}

Output:-

Enter the 10 element of the array
1 2 3 4 5 6 7 8 9 0
The element of the array is:-
1 2 3 4 5 6 7 8 9 0



Leave a Reply

Your email address will not be published.