Tuesday, 26 August 2014

Filled Under:

C Program to Access Elements of an Array Using Pointer

Share
Here is simple C program is given which access the element of an array using pointer.This program accept five integer value and access  these value by using pointer and print these value on output screen.

C Program to Access Elements of an Array Using Pointer

C Program to Access Elements of an Array Using Pointer




#include <stdio.h>
int main()
{
   int val[5], i;
   printf("\nEnter elements: ");
   for(i=0;i<5;++i)
     scanf("%d",val+i);
   printf("\nYou entered: ");
   for(i=0;i<5;++i)
      printf("%d\n",*(val+i));
   return 0;
}


Output

 Enter elements: 23 43 54 55 21
 You entered: 23 43 54 55 21