I'm trying to do a program that gets the averages of positive and negative numbers in an array that consists of numbers I have to read from a file.txt. I'm having trouble in how to put the numbers in the file.txt into the array and I can't seem to understand how to find the averages of the positive and negative numbers. I did some of the work and they have to specifically be with functions. My file.txt consists of the numbers: 2 17 -5 0 20 15 -16 -3 -2 14 -1 12 1 -5 -100 15 22 -5 68 -13
Here's my code:
#include <iostream>
#include <fstream>
using namespace std;
void ReadList(int Array[ ], int N)
{
N = 0;
ifstream input("file.txt");
Array [
return;
}
void Avgs (int Array[], int N, int& Ave, int& aveP, int& AveN)
{
return;
}
int Large (int Array[], int N)
{
int max = 0;
int lrgst;
Array [] = Array[20];
for (int i = 1; i < 20; i++)
if (Array[max] < Array[i])
max = i;
lrgst = Array[max];
return lrgst;
}
void Display(int Array[ ], int N, int Ave, int AveP, int AveN, int Max)
{
int sum;
Array [] = Array[20];
for (int i = 0; i < 20; i++)
{
sum+=Array[i];
Ave = sum/20;
cout << "Average:" << Ave << endl;
}
for (aveP = 0; aveP < 20; aveP++)
{
sum+=Array[aveP];
aveP = sum/Array[aveP];
cout << "Average of positive numbers is: " << aveP << endl;
}
for (aveN = 0; aveN < 20; aveN++
{
sum+=Array[aveN];
aveN = sum/Array[aveN];
cout << "Average of negative numbers is: " << aveN << endl;
}
return;
}