Skip to content

Instantly share code, notes, and snippets.

@anonur
Last active April 4, 2019 19:14
Show Gist options
  • Save anonur/8fd887c866b3bfe79c71ccff50f0182d to your computer and use it in GitHub Desktop.
Save anonur/8fd887c866b3bfe79c71ccff50f0182d to your computer and use it in GitHub Desktop.
Finding summary of numbers in an array from first elements pointer
#include<stdio.h>
int array1(int a[],int n)
{
int *p,sum=0,counter;
p=&a[0];
for(counter=0;counter<n;counter++)
sum+=*(p+counter);
return sum;
}
int main()
{
int num[10]={1,2,3,4,5,6,7,8,9,10};
int f;
f=array1(num,10);
printf("Sum of numbers are: %d",f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment