I changed main to int main(), although it really shouldn't have a big impact on the output but lets just use int main() for the sake that int main() is how the standard wants it.
I added
#include <stdlib.h>
to the code because system() comes from stdlib.h
I find it odd that your compiler compiled it without including stdlib.h
If problems persist it may have something to do with the way your compiler links perhaps.
here is the code, (modified)
Code:
#include <stdio.h>
#include <stdlib.h>
/*Structure declaration*/
struct employee
{
long id_number;
float wage;
float hours;
float overtime;
float gross;
};
/*Variable declaration (global)*/
struct employee data[5] = { {98401, 10.60}, {526488, 9.75}, {765349, 10.50},
{34645, 12.25}, {127615, 8.35} };
struct employee get_hours (struct employee data[])
{
int temp, i = temp;
for (temp=1; temp<6; ++temp)
{
printf ("Enter employee #%06d hours worked: ", data[temp-1].id_number);
scanf ("%f", &data[temp-1].hours);
}
return (data[i]);
}
struct employee calculate_overtime (struct employee data[])
{
int temp, i = temp;
for (temp=1; temp<6; ++temp)
{
if (data[temp-1].hours > 40)
data[temp-1].overtime = data[temp-1].hours - 40;
else
data[temp-1].overtime = 0;
}
return (data[i]);
}
struct employee calculate_gross (struct employee data[])
{
int temp, i = temp;
for (temp=1; temp<6; ++temp)
{
if (data[temp-1].overtime > 0)
data[temp-1].gross = (data[temp-1].wage * 40) +
((data[temp-1].wage * 1.5) * data[temp-1].overtime);
else
data[temp-1].gross = (data[temp-1].wage * data[temp-1].hours) +
((data[temp-1].wage * 1.5) * data[temp-1].overtime);
}
return (data[i]);
}
void output (struct employee data[])
{
int temp;
printf ("\n\n");
printf ("--------------------------------------------------------\n");
printf ("Clock # Pay Rate Hours OT Gross Pay\n");
printf ("--------------------------------------------------------\n");
for (temp=1; temp<6; ++temp)
{
printf ("%06d $%5.2f %5.1f %5.1f $%6.2f\n",
data[temp-1].id_number, data[temp-1].wage, data[temp-1].hours,
data[temp-1].overtime, data[temp-1].gross);
}
}
int main ()
{
int i;
/*Execute functions*/
for (i=1; i<6; ++i)
{
get_hours (data);
calculate_overtime (data);
calculate_gross (data);
}
output (data);
printf ("\n");
system("PAUSE");
return 0;
}
here is the output I got, if this is not correct then check the code...
Code:
Enter employee #098401 hours worked: 4
Enter employee #526488 hours worked: 12
Enter employee #765349 hours worked: 13
Enter employee #034645 hours worked: 15
Enter employee #127615 hours worked: 10
Enter employee #098401 hours worked: 8
Enter employee #526488 hours worked: 8
Enter employee #765349 hours worked: 8
Enter employee #034645 hours worked: 8
Enter employee #127615 hours worked: 8
Enter employee #098401 hours worked: 8
Enter employee #526488 hours worked: 8
Enter employee #765349 hours worked: 8
Enter employee #034645 hours worked: 8
Enter employee #127615 hours worked: 8
Enter employee #098401 hours worked: 8
Enter employee #526488 hours worked: 8
Enter employee #765349 hours worked: 8
Enter employee #034645 hours worked: 8
Enter employee #127615 hours worked: 8
Enter employee #098401 hours worked: 8
Enter employee #526488 hours worked: 8
Enter employee #765349 hours worked: 8
Enter employee #034645 hours worked: 8
Enter employee #127615 hours worked: 8
--------------------------------------------------------
Clock # Pay Rate Hours OT Gross Pay
--------------------------------------------------------
098401 $10.60 8.0 0.0 $ 84.80
526488 $ 9.75 8.0 0.0 $ 78.00
765349 $10.50 8.0 0.0 $ 84.00
034645 $12.25 8.0 0.0 $ 98.00
127615 $ 8.35 8.0 0.0 $ 66.80
Press any key to continue . . .