-3

I am trying to write code using multiple functions that simply gets average days employees missed for a company i tried to use global identifiers here is my code

#include<iostream>
using namespace std;
int days;
int numberemployees;
int main()
{
    int days;
    int numberemployees;
    double average;
    cout<<"How many employees do you have";
    cin>>numberemployees;
    daysmissed;
    averagedays;

    return 0;
}

int daysmissed(int)
{
    int days;
    cout<<"How many total days where missed by employees this year";
    cin>>days;
    return days;
}

double averagedays(double)
{
    double average;
    average=days/numberemployees;
    return average;
}
jmstoker
  • 3,315
  • 22
  • 36

1 Answers1

1

To create a function (other than int main()), you need two parts, the declaration and the definition. The declaration is usually at the top of your code and looks like this:

int foo(int); //foo(int) declaration

The declaration is necessary for code to use the function before it is defined. The other part of a function is the definition, where you define the function:

int foo(int i)
{
     return i + 1;
}

Your mistake was you forget the declaration and the messed up the definition

yizzlez
  • 8,757
  • 4
  • 29
  • 44