Why am I getting multipleerror: class, interface, or enum expected when I try to
ID: 3528209 • Letter: W
Question
Why am I getting multipleerror: class, interface, or enum expected when I try to build this code. Post the correct code in the comments for a lifesaver.
#include<iostream>
using namespace std;
double avg(int a[], int k)
{
double sum = 0;
for(int i=0; i<10; i++)
sum = sum + a[i];
return (sum/10.0);
}
int main()
{
double a[10];
for(int i=0; i<10; i++)
{
cin >> a[i];
}
cout << avg(a,10) << endl;
for(int i=0; i<10; i++)
{
if(a[i] > avg(a,10)
cout << a[i];
}
return 0;
}
Explanation / Answer
There is no need to pass 10 in avg function as you have not utilized the variable 'k' in your avg function.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.