Search This Blog

Saturday 19 November 2016

C Program to Access Elements of an Array 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: \n");
   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

No comments:

Post a Comment