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
Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.
Related Articles
Basic Courses
Advance Courses