Code:
#include <stdio.h>
float ot_pay(int, float[], float[]);
float calculate_gross(int, int, float[], float[], float[]);
main()
{
/*Variables*/
int employees, x;
float hours[30], rate[30], fed_tax[10], net_pay[10], overtime[10];
struct info
{
char first[30], last[30];
};
struct info name[100];
printf ("*****WELCOME TO THE PAYROLL CALCULATOR*****\n\n");
for (x = 1; x <=1; ++x) /*Loop1 - Get Number of Employees*/
{
printf("Please enter # of employees(1-10): ");
scanf("%i",&employees);
if (employees > 10)
{ printf ("Invalid Entry\n");
--x;
}
if (employees < 1)
{ printf ("Invalid Entry\n");
--x;
}
}
for (x = 1; x <=employees; ++x) /*Loop 2 - Get info for employees*/
{
printf ("\nEnter first and last name of employee #%i: ",x);
scanf("%s %s",name[x].first, name[x].last);
printf("Enter pay rate for employee #%i: ",x);
scanf("%f", &rate[x]);
printf("Enter hours worked for employee #%i: ",x);
scanf("%f", &hours[x]);
if (hours[x]<=0)
{ printf ("Invalid Entry\n");
--x;
}
else if(rate[x]<=0)
{printf ("Invalid Entry\n");
--x;
}
if(hours[x] > 40)
{ot_pay(x, hours, rate); /*Call OT function if necessary*/
}
}
calculate_gross(x, employees, hours, rate, overtime);
}
float ot_pay(int x,float hours[],float rate[])
{
float overtime[10];
overtime[x] = (hours[x]-40)*rate[x]*1.5;
printf("OT $%.2f\n\n",overtime[x]);
return overtime[x];
}
float calcualte_gross(int x, int employees, float hours[], float rate[], float overtime[])
{
for (x = 1; x <= employees; ++x)
{
float gross_pay[30];
gross_pay[x]=hours[x]*rate[x]+overtime[x]/3;
return gross_pay[x];
}
}
*undefined reference to calculate_gross* in red
Dont know why this is not working. Any advice???