The receive function is giving me problems. I'm trying to get it to accept the number of employees as it's parameter.Code:#include <iostream>
using namespace std;
int ask(void);
int receive(int);
float calculate(int, int);
int main()
{
int ne;
int na;
float calc;
ne = ask();
na = receive(ne);
calc = calculate(ne, na);
ask();
receive();
cout << "The average number of days absent is " << calc << endl;
return 0;
}
int ask(void)
{
int number_of_employees;
cout << "Enter the number of employees in the company." << endl;
cin >> number_of_employees;
if(number_of_employees < 1)
{
cout << "Invalid input" << endl;
cin >> number_of_employees;
}
return 0;
}
int receive(int number_of_employees)
{
int sum = 0;
int days_absent;
cout << "Enter the number of absences for each employee" << endl;
for (int i= 0; i < number_of_employees; i++)
{
cin >> days_absent;
if(days_absent < 0)
cout << "Invalid input" << endl;
else
sum += days_absent;
}
return sum;
}
float calculate(int number_of_employees, int number_of_absences)
{
return (float) number_of_absences/number_of_employees;
}