C PROGRAM CODE
#include<stdio.h>
main()
{
int i,n,sum=0,*ptr;
printf("\n ENTER THE RANGE OF ARRAY:\n ");
scanf("%d",&n);
int var[100-1];
printf("\n ENTER VALUES IN ARRAY:\n ");
for(i=0;i<n;i++)
{
scanf("%d",&var[i]);
}
ptr=&var[0];
//you can also use ptr=var;
for(i=0;i<n;i++)
{
sum+=*ptr;
ptr++;
}
printf("\n SUM OF GIVEN NUMBERS = %d\n",sum);
}
No comments:
Post a Comment