Last active
April 4, 2019 19:14
-
-
Save anonur/8fd887c866b3bfe79c71ccff50f0182d to your computer and use it in GitHub Desktop.
Finding summary of numbers in an array from first elements pointer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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