#include <iostream>
usingnamespace std;
double averagef (double x[]);//prototyping function
int main()
{
double even [8][5];//array to store even numbers
for(int rows =0;rows<8;rows++)//loop for the rows
{
for (int column = 0;column<5;column++)//loop for the column
{
for(int i = 0;i<100;i++)//loop to count to 100
{
if ( i % 2== 0 )//if statement to check if the number is even
{
even [i][i] = i;//store the number if even
}//end if
}//end counting loop
}//end of column loop
}//end rows loop
cout<<"The average of the 40 even numbers is:"<<averagef(even);//calling //functiuon
return 0;
}
double averagef (double x[])//function for finding average
{
double sum;
double average;
for (int j = 0;j<40;j++)//loopp to take the first 20 numbers
{
sum=sum+x[j];/add them
}
average=sum/40;//divide by 40
return (average);//return
}
int even[8][5];
int row = 0;
int column = 0;
for(int nCount = 1; nCount < 101; nCount++)
{
if(nCount %2 == 0) // test for even.
{
even[row][column] = nCount; // set the position in the array.
// increment the positions in the array.
column++;
if(column > 4)
{
column=0;
row++;
if(row > 7) break; // array bounds check..
}
}