Take an array and print sum of all even number using fucntion and pointer
Answers
Answered by
0
Answer:
Find even numbers in an array using pointers
c
I am trying to find the even numbers in the array arr[100]; using pointers.
int main()
{
int ar[100],*i,*j,n=0,even,*peven=&even;
scanf("%d",&n);
for(i=ar;i<ar+n;i++)
{
scanf("%d",ar+n);
}
for(i=ar;i<ar+n;i++)
{
*peven=0;
for(j=ar;j<ar+n;j++)
{
if((*ar+n)%2==0)
{
(*peven)++;
}
}
printf("%d",*peven);
}
return 0;
}
Share Improve this question Follow
Similar questions