#include <stdio.h>
double IncomeTAX(double i)
{
double tax;
if(i <= 120000)
tax = 0;
else
tax = (i - 120000) * 15/100;
return tax;
}
int main(void)
{
double a, b;
printf ("Enter the annual income: ");
scanf ("%lf", &b);
a = IncomeTAX(b);
printf ("Income Tax is %.2lf\n", a);
}
When I try to run the program in this manner it works, but when I separate the procedure, the program compiles but gives a junk value. But if I change the datatype in the procedure from 'double' to 'long' the program works even if the procedure is compiled separately.
Can anyone tell me what is the reason behind this?