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;
}

Edited 4 Years Ago by juljan30: mistaken title

remove the brackets on lines 15 and 18 because they are not necessary. Also format the program a little better to make it easier for you to follow the flow of the program.

    #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;
    }

Edited 4 Years Ago by Ancient Dragon

When asking for help, EXPLAIN what problem you are having. Do not expect us to try to figure out what it does wrong -- tell us!

This article has been dead for over six months. Start a new discussion instead.