Apr

04

//———————————————— arp2.c ———————————–

// find the sum of array elements using pointer

#include<stdio.h>
void main(){
int a[5];
int *ptr;
int i,sum=0;
printf(“Enter Five Numbers:\n”);
for(i=0;i<5;i++){
scanf( “%d”,&a[i]);
}
ptr=a;
for(i=0;i<5;i++){
sum=sum+*(ptr+i);
}
printf(“Addition is: %d\n”,sum);
}


Leave a Reply