``````calculate and display the average of all even values .

#include<stdio.h>

int main()
{

int numArrays[] = {2, 67, 23, 5, 7, 34, 14, 4, 8, 62};
int i, sum=0, ave=0;

for(i=1; i<10; i++)
{
if(numArray[i]%2==0)
printf("%d", numArray[a]);
total+=numArray[a];
sum=sum+total;

printf("the total of all even number is; %d", sum);
}
ave=(float)sum/n;
printf("the average of all even numbers is: %f", ave);

returtn 0;

)
``````

Your program is missing { and } around the if statement because the if statement consists of multiple lines

``````if(numArray[i]%2==0)
{
printf("%d", numArray[a]);
total+=numArray[a];
}
``````

Line 20 also has a problem: variable n was never declared, and the result will only be an integer because ave …

## All 4 Replies

Your program is missing { and } around the if statement because the if statement consists of multiple lines

``````if(numArray[i]%2==0)
{
printf("%d", numArray[a]);
total+=numArray[a];
}
``````

Line 20 also has a problem: variable n was never declared, and the result will only be an integer because ave is an integer.

``````calculate and display the average of all even values .

#include<stdio.h>

int main()
{

int numArrays[] = {2, 67, 23, 5, 7, 34, 14, 4, 8, 62};
int i, sum=0,
double ave=0;

for(i=1; i<10; i++)
{
if(numArray[i]%2==0)
{
printf("%d", numArray[a]);
total+=numArray[a];
}
{
sum=sum+total;

printf("the total of all even number is; %d", sum);
}
ave=(float)sum/n;
printf("the average of all even numbers is: %f", ave);

returtn 0;
}