Hi,
I runned that program with int variables and was OK but when I changed the type of
pay_calc(),*emp_rate,pay
from integer to float I failed ..Please Help

main()
{
int *emp_no,*emp_works;
int pay_calc(),*emp_rate,pay;
char *emp_unit,ans,another();
system("cls");
do {
input(&emp_no,&emp_works,&emp_rate,&emp_unit);
pay=pay_calc(emp_works,emp_rate,emp_unit);
pay_slip(emp_no,emp_works,emp_rate,emp_unit);
cash(pay);
} while (another()=='y');
return 0;
}


char another()
{
char answer;
printf("\nAnother Employee (y/n) : ");
scanf("\n");
scanf("%c",&answer);
return (answer);
}


input (emp_n,emp_w,emp_r,emp_u)
int *emp_n,*emp_w;
int *emp_r;
char *emp_u;
{
printf ("\n Enter the Employee number : ");
scanf("%d",emp_n);
printf ("\n Enter the Employee Pay Based unit (weeks or hours) : ");
scanf("\n");
scanf("%c",emp_u);
if ((*emp_u)=='w')
{
printf ("\n Enter the number of weeks :");
scanf("%d",emp_w);
printf ("\n Enter the rate of paying for each week :");
scanf("%d",emp_r);
}
if ((*emp_u)=='h')
{
printf ("\n Enter the number of hours :");
scanf("%d",emp_w);
printf ("\n Enter the rate of paying for each hour :");
scanf("%d",emp_r);
}
return 0;
}

int pay_calc(emp_w,emp_r,emp_u)
int emp_w;
int emp_r;
char emp_u;
{
int p=0.0;
p=(emp_r)*(emp_w);
if (emp_u=='h')
printf ("\nThat pay for hours %d worked with rate %d is = %d",emp_w,emp_r,p);
if (emp_u=='w')
printf ("\nThat pay for Weeks %d worked with rate %d is = %d",emp_w,emp_r,p);
return ((emp_r)*(emp_w));
}

Recommended Answers

All 2 Replies

input (emp_n,emp_w,emp_r,emp_u)
int *emp_n,*emp_w;
int *emp_r;
char *emp_u;

OMG! what book are you reading anyway. We haven't coded like that in over 20 years, since K&R. Your compiler will like you a lot better if you code it like below.

input (int *emp_n,int *emp_w,int *emp_r,char *emp_u)

what do you mean "it failed" ? what compiler are you using? what were the errors. Post the code that failed.

And next time use CODE tags. :)

You need prototypes. Valid ones. Put this near the top of your program:

int pay_calc(int emp_w, int emp_r, char emp_u);

Or double or float or whatever it is you want.

If there is no prototype for a function, the compiler assumes it takes int arguments. Turn on your warnings.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.