Using the debugger, as suggested by
ppolymorphe I was able to spot the bug, your are messing with loop indices (
i
,
j
) in the
locUnLucky
function. It should be:
void locUnLucky (double sal[][2], int lucky[], int totalEmps)
{
int i, j;
double grossSalary, netSalary;
for (i = 0; i < totalEmps; i++)
{
grossSalary = sal[i][0];
netSalary = sal[i][1];
for (j = 0; j < totalEmps; j++)
{
if(grossSalary < sal[j][0] && netSalary > sal[i][1])
{
lucky[i] = 1;
}
}
}
}
However, even with such a fix, your code has a logical flaw: you should compare each employee salary with the average salary, in order to get meaningful info.