Fix this code so I don\'t get errors and post the full revised code as an answe
ID: 3528214 • Letter: F
Question
Fix this code so I don't get errors and post the full revised code as an answe pleaser.
#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;
}
This is the program I am trying to accomplish:
Write a program that takes 10 floating-point numbers listed most often. The program displays the average of the numbers followed by all of the numbers that are greater than the average. As part of your design, write a method that takes an array of doubles as a parameter and returns the average of the data in the array. Please use methods to do each task. Pass your arrays to the method to complete each task.
Explanation / Answer
#include using namespace std; double avg(int a[], int k) { double sum = 0; for(double i=0; i a[i]; } coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.