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;
}
juljan30
0
Newbie Poster
Recommended Answers
Jump to PostYour variable "i" in the for loop starts with 1.Make it 0 and then execute it.
All 3 Replies
amrita111
4
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.