by Dinesh Thakur Category: Function and Pointer

An individual element of an array may be regarded as a variable of the type declared in the declaration of the array. All the operators that can be applied to a variable of that type are applicable to the elements of array as well. Program, the array elements are subjected to arithmetic operations with the help of pointers.

#include <stdio.h>

int main()
{
  int i;
  int AR [] = {2,3,4,5 }, BR [4] ,CR [4] ;
  int* pAR = AR ;
  clrscr();
  printf("Elements of CR and BR are obtained from AR.\n");
  for(i=0 ; i<4; i++)
    {
      BR[i] = *(pAR +i)* *(pAR +i);
      CR[i] = *(pAR +i)**(pAR +i)**(pAR +i) ;
      printf("AR[%d] = %d\t BR[%d] = %d\t CR[%d] = %d",i,AR[i],i,BR[i] ,i,CR[i]);
      printf ("\n");
    }
      return 0;
}
The output is as given below. The explanation is already given above

C Program manipulating array elements with pointers

Popular Article