Access Elements of an Array Using Pointer
Course- C >
This program declares the array of five element and the elements of that array are accessed using pointer.
Source Code to Access Array Elements Using Pointer
#include <stdio.h>
int main(){
int data[5], i;
printf("Enter elements: ");
for(i=0;i<5;++i)
scanf("%d",data+i);
printf("You entered: ");
for(i=0;i<5;++i)
printf("%d\n",*(data+i));
return 0;
}
Output
Enter elements: 1 2 3 5 4 You entered: 1 2 3 5 4