Ok, first thing, when using one dimensional arrays with functions you don't pass the bounds of the array, so your original function should become:
Code:
Double pay_calc(double hour[10], double[10]){...}
// should be:
double pay_calc(double hour[], double rate[], int hourArraySize, int rateArraySize){...}
// and the declaration would be:
double pay_calc(double[], double[], int, int);
Then, within your function the 'for' loops would look like:
Code:
for(i=0; i<hourArraySize, i++)
{
do stuff to hour[i];
}
Another thing I can notice is your return value in the pay_calc function is incorrect:
return pay_calc[10];
This would return the value held at pay_calc[10], which is a piece of memory you don't own!
If you want to return an array you will have to return a pointer to it. So the function becomes:
double *pay_calc(......)
and you return:
return pay_calc;
The most important thing about learning to use arrays with functions is realising the connection between arrays and pointers, look this up and that should point you in the right direction (no pun intended)!
As for your problem of not being able to check for an input of zero, your error checking code:
Code:
if (num1[j]<0 || num2[j]<0)
{
printf("\nplease enter a positive value!!!");
}
should be in your loops because, as it is, you are only checking a single element of each array (num1[j]). You should check that value just after it has been entered (still inside the for loop). So you get:
Code:
for (j=0; j<10; j++)
{
printf("\nplease enter rate for employee:"j+1); // j+1??? what is this intended to do?
do
{
scanf("%lf",&num2[j]);
if(num2[j] < 0)
printf("\nplease enter a positive value!!!");
}while(num2[j] < 0);
}
hope that helps
dt