cant seem to figure out what the error is :(

#include<iostream>
using namespace std;

//prototyping variables
void averageCal(double a[]);
void productCal (double p[]);
void sumCal (double s[]);


int main ()
{

double userinputs [5];//storing the user inputs in a array


for(int i=0; i<5; i++)//suing a for loop to cycly and store the user inputs
{
cout<<"Please enter a value: ";
cin>>userinputs[i];
    }//end of for loop for user inputs




//displaying the average,product and sum on screen
cout << "The average of the 5 numbers are: " << averageCal(userinputs[]) << endl;
cout << "The product of the 5 numbers are: " << productCal(userinputs[]) << endl;
cout << "The sum of the 5 numbers are: " << sumCal(userinputs[]) << endl;





    return 0;
}


//function for finding the average
void averageCal (double a[])
{
    //initialize variables
double addition=0;
double average_ans = 0;

for (int c = 0; c < 5; c++)//for loop to add the numbers
    {addition = addition + a[c];}//end of for loop

     average_ans = addition / 5;//dividint the numbers by 5

    cout << average_ans << endl;

}//end of function


//function for finding the product
void productCal (double p[])
{//initializing variables
    double multiplication= 1;
    double product_ans= 0;

    for (int m = 0; m < 5; m++)//for loop to cycle through the user numbers and multiply them
    {multiplication = multiplication * p[m];}//end of for


    cout << multiplication << endl;
}


//function fo rfinding the sum
void sumCal (double s[])
{//variables
    double addition= 0;


    for (int a = 0; a < 5; a++)//for loop
    {addition = addition + s[a];}//end of for

 cout << addition<< endl;
}

lines 26-28: you can't put functions that have no return value in cout statements. What do you expect cout to print? It can't print what the function doesn't return.

#include<iostream>
using namespace std;

//prototyping variables
void averageCal(double a[]);
void productCal (double p[]);
void sumCal (double s[]);


int main ()
{

double userinputs [5];//storing the user inputs in a array


for(int i=0; i<5; i++)//suing a for loop to cycly and store the user inputs
{
cout<<"Please enter a value: ";
cin>>userinputs[i];
    }//end of for loop for user inputs




//displaying the average,product and sum on screen
averageCal;
productCal;
sumCal;





    return 0;
}


//function for finding the average
void averageCal (double a[])
{
    //initialize variables
double addition=0;
double average_ans = 0;

for (int c = 0; c < 5; c++)//for loop to add the numbers
    {addition = addition + a[c];}//end of for loop

     average_ans = addition / 5;//dividint the numbers by 5

    cout << "The average of the 5 numbers is: " <<average_ans << endl;

}//end of function


//function for finding the product
void productCal (double p[])
{//initializing variables
    double multiplication= 1;
    double product_ans= 0;

    for (int m = 0; m < 5; m++)//for loop to cycle through the user numbers and multiply them
    {multiplication = multiplication * p[m];}//end of for


   cout << "The product of the 5 numbers is: " << multiplication << endl;
}


//function fo rfinding the sum
void sumCal (double s[])
{//variables
    double addition= 0;


    for (int a = 0; a < 5; a++)//for loop
    {addition = addition + s[a];}//end of for

 cout << "The sum of the 5 numbers are: "<< addition<< endl;
}
averageCal;
productCal;
sumCal;

should be

averageCal(userinputs);
productCal(userinputs);
sumCal(userinputs);

They are functions. You should call them accordingly.

Edited 3 Years Ago by Lucaci Andrew

This question has already been answered. Start a new discussion instead.