#include<stdio.h>
void pass(int *);
int main(void)
{
int *array,i=0,*a;
int b=10;
array=(int*)calloc(sizeof(int)*b);
printf("Enter the %d elements of the array :: ",b);
for(i=0;i<10;i++)
{
scanf(" %d",&array[i]);
}
a=array;
pass(a);
for(i=0;i<10;i++)
{
printf("%d ",array[i]);
}
return 0;
}
void pass(int *passed)
{
int *p,i=0,s=0;
printf("\n\nEnter a digit to add to each of the element of the array::");
scanf("%d",&s);
printf("\n\nAfter addition using pointer arithmetic::\n\n");
for(p=passed,i=0;i<10;i++,p++)
{
*p=*p+s;
}
printf("\n");
}
No comments:
Post a Comment