Write a program to implement the concept of pointer to array access in functions.

#include
#include
main()
{
int *p,i,n;
void modify(int *,int);
clrscr();
cout<>n;
for(i=0;i<n;i++)
{
cout<<"n A["<<i<>*(p+i);
}
cout<<"nnn";
cout<<"n Before calling the function for modification elements are :n";
for(i=0;i<n;i++)
{
cout<<"n A["<<i<<"]="<<*(p+i);
}
modify(p,n);
cout<<"n After modification each element incremented by 500 n";
for(i=0;i<n;i++)
{
cout<<"n A["<<i<<"]="<<*(p+i);
}
getch();
return(0);
}
void modify(int *t, int s)
{
int j;
for(j=0;j<s;j++)
{
*(t+j)=(*(t+j)+500);
}
}

Leave a Reply