The question is :
- Read 8 values from the user.
- Display the average of the values .
- Copy those (values < average) in another array .
-## Display the average of the second array .
It's not Displaying the correct average !!!!!!!!!!!!!!!!!
The code is :
#include<iostream>
using namespace std;
void main()
{
int valu1[8];
for(int i=0 ; i<8 ; i++)
{
cin>>valu1[i];
}
int sum = 0;
for(int i = 0; i < 8; i++)
{
sum += valu1[i];
}
int average = sum / 8;
cout<<average<<endl;
int valu2[8];
int count=0 ;
for (int j=0; j<8 ; j++)
{
if(valu1[j]< average)
{
valu2[count]= valu1[j];
count++;
}
}
int sum2 = 0;
for(int h = 0; h < 8; h++)
{
sum2 += valu2[h];
}
int average2 = sum2 / 8;
cout<<average2<<endl;
}