I am writing this program to use user defined functions, must be return value functions as well. It is a modification to a program already written, and am having a couple errors that I just cannot figure out. Here is the code, the errors I am getting when I compile the program are below the code. Any help is appreciated. Thank you.

//Program to calculate the average number of minutes 
//excersized per week by an individual.

#include <iostream>
using namespace std;

int fsum(int sum, int number, int num_days, int counter);
double Average(int sum, int number, double Average);

int main()
{
  int counter = 0 ;
  int sum = 0 ;
  const int limit = 7 ;

  cout << "Enter number of minutes excercised per day." << endl;
  cout << "Leave a space between each number of minutes." << endl;
  cout << "Do not enter a value for zero minutes." << endl;
  cout << "The first day of the week is Monday." << endl; \
    
  int num_days = 0 ;
  while( counter < limit )
    {
      int number ;
      cin >> number ;
      if (number > 0)
   	{    
  			cout << "The total minutes excersized is " << fsum << endl;
		}  
  if( num_days > 0 )
  {
    cout << "The average minutes excersized per day during this week is "
          << Average << endl;
    cout << "The number of days excercised is " << num_days << endl;
  }
  return 0;  
} 



int fsum(int number, int sum, int num_days, int counter);
{	
		int number;
        sum = sum + number;
        num_days = num_days + 1;
    
      counter = counter + 1 ;
	return (sum);
}


double Average (int sum, int counter, double Average);
{		{
		Average = sum / counter;
		}
			return Average;
}

Errors I am getting:

ExcerciseCalculator.cpp:54: non-lvalue in assignment
ExcerciseCalculator.cpp:56: warning: return to `int' from `double (*)(int, int, double)' lacks a cast
ExcerciseCalculator.cpp:59: parse error at end of input

Recommended Answers

All 2 Replies

rename the parameter to something else other than Average. There is no point to that parameter anyway, just make it a local variable and get rid of that parameter.

1. remove the semicolon at the end of line 32

2. remove the extraneous braces on line 53 and 55

3. main() is missing a closing brace somewhere. Use your spacebar to align the blocks of code better so you can easily see where the braces should be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.