#include <iostream>
#include <iomanip>
#include <conio.h>
usingnamespace std;
//Function Prototypes
void numEmploy();
void numAbsent(int);
void Avg(double, double);
//Main
int main()
{
numEmploy();
numAbsent();
average = Avg();
cout << "The average number of days a company's employees are absent is " << average << endl;
getch();
return 0;
}
//Function Declarations
//numEmploy function
void numEmploy()
{
cout << "How many people are employed at the company?\n";
cin >> num;
if (num < 1)
{
cout << "Please enter a number greater than 0.\n";
cin >> num;
}
return num;
}
//numAbsent function
void numAbsent(int)
{
int total = 0;
int abs;
while (num)
{
total += abs;
num++;
cout << "Enter the number of days employee " << num << "missed: ";
cin >> abs;
}
return total;
}
//avg function
void Avg(num, absent)
{
(num + absent) / num = total;
return total;
}
i have not gone throug the code properly...htere are a lot of mistakes in it......
you have written average = Avg( );
but you have not defined what average is.....also the function Avg requires two arguments(you did not pass any arguments to it).....
I think uou have a misconception that whrn you call a function(say numEmploy)...the variables defined in the function become global.....That is not right...
#include <iostream>
usingnamespace std;
//Function Prototypes
int numEmploy();
float Avg(int, int);
int numAbsent(int);
//Main
int main(){
int num=numEmploy();
//numAbsent(num);
floathj average = Avg(num,numAbsent(num));
cout << "The average number of days a company's employees are absent is " << average << endl;
getch();
return 0;
}
//Function Declarations
//numEmploy function
int numEmploy()
{
int num;
cout << "How many people are employed at the company?\n";
cin >> num;
if (num < 1)
{
cout << "Please enter a number greater than 0.\n";
cin >> num;
}
return num;
}
//numAbsent function
int numAbsent(int num)
{
int total = 0;
int abs,tot=0;
while (tot<num)
{
tot++;
cout << "Enter the number of days employee " << tot << "missed: ";
cin >> abs;
total += abs;
}
return total;
}
//avg function
float Avg(int num,int absent){
float total;
total= (1.0* absent )/ num;
return total;
}
any further explanation is not good.....
i hope you understand what ur mistake is....if not better refer the theory again