View All C Programs

 Previews Example  View All C Programs Next Example 

Program to Access Elements of an Array Using Pointer in C

This program declares the array of five element and the elements of that array are accessed using pointer.
#include <stdio.h>
#include <conio.h>
 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));
   getch();
}
Result
Enter elements: 9
8
7
6
5

You entered: 9
8
7
6
5