Here is my code. I have a warning that
(127) : warning C4715: 'ComputeSum' : not all control paths return a value
#include <iostream>
using namespace std;
const int MAX = 10;
// Function prototypes, i.e., declarations for the functions we have created
void ReadInput (int A[], int number, int i);
void ProcessData (int A[]);
double ComputeSum (int sum, int A[]);
void ComputeMean (double mean, int sum);
void PrintData (int sum, double mean);
double mean (int sum, int i) ;
// compute an average, given a sum and the amount of numbers
// **************************************************************************
//Main Module
int main()
{
// variable definitions
char proceed ; // start collecting data? coded y/n
int sum ; // declare sum as integer
double mean; // declare mean as a double
int i ; // declare i as integer
int number; //declare number as integer
// initialize variables
i = 0;
number = 0;
sum = 0 ;
mean = 0;
int A[MAX] ; // declare the size of the array
cout << "This program computes the average of 10 numbers" ;
cout << endl ;
cout << "Do you want to start data entry now ? (y/n)" ;
cin >> proceed ;
cout << endl ;
while (proceed == 'y')
{
ReadInput (A, number, i);
ProcessData (A);
}
ComputeSum (sum, A);
ComputeMean (mean, sum);
PrintData (sum, mean);
return 0;
}
//Input Module (A)
void ReadInput (int A[10], int number, int i)
{
for ( i = 0; i < MAX; i++) //create for loop
{
cout << "Enter a positive number:" ;
cin >> number ;
}
}
void ProcessData (int A[MAX], int number, int i)
{
if (number <= 0) // if else statement (INSIDE the loop) to calculate for user error
{
cout << "Invalid Entry! Enter a number greater than zero." ;
}
else if (number > 0)
{
A[i] = number ;
cout << endl;
}
}
// Calculation Module (sum, mean)
double ComputeSum (int sum, int A[])
{
for (int i = 0; i < MAX; i++)
{sum = sum + A[i] ;
return sum;
}
}
void ComputeMean (double mean, int sum)
{
{
mean = 1.0 * sum / MAX;
}
cout << endl ;
}
// Output Module (sum, mean)
void PrintData (int sum, double mean)
{
cout << "The sum is" << sum << endl ;
cout << "The average is" << mean << endl ;
}