jeudi 5 mars 2015

Returning A Float Array from a function



findwitholding(Gross_Pay,FDH_Witholding,FW_TAXRATE);
findwitholding(Gross_Pay,FDH_Witholding,SW_TAXRATE);
findwitholding(Gross_Pay,FDH_Witholding,HOSPITALIZATION);


How can I return the the values from all three functions called?



void findwitholding(farray Gross_Pay, farray FDH_Witholding,
float Witholding)
{
for(int i = 0; i < ISIZE; i++)
FDH_Witholding[i] = Gross_Pay[i] * Witholding;
}


How can I pass it by value? Like this?



typedef float farray[5] //we have to use typedef
farray FED,STATE,HOSPITAL;

FED = findwitholding(Gross_Pay,FDH_Witholding,FW_TAXRATE);
STATE = findwitholding(Gross_Pay,FDH_Witholding,SW_TAXRATE);
HOSPITAL = findwitholding(Gross_Pay,FDH_Witholding,HOSPITALIZATION);


If so, should it be like this for the function?



*farray* findwitholding(farray Gross_Pay, farray FDH_Witholding,
float Witholding)
{
for(int i = 0; i < ISIZE; i++)
FDH_Witholding[i] = Gross_Pay[i] * Witholding;
return FDH_Witholding;
}



Aucun commentaire:

Enregistrer un commentaire