Subfunctions

Can somebody please tell me why this will not run I keep getting told that "value" is undefined on line 2 and 47 and end of the program, on line 29 I get the error "term does not evaluate to a function taking 1 arguments, and on line 49 I get the error for the term calcTax function-style initializer appears to be a function definition. I checked similar programs and they look the same, all though I am new at this, I am not sure what I need to change to make this work, I have been staring at this for like an hour and every change gets me a new error.

#include <stdio.h>
double calcTax(value);

int main()
{
int PropertyID;
double PropertyValue;
double TaxDue;
double TotalTaxDue;
double value;
double Tax;

printf("\nEnter PropertyID: ");
fflush(stdin);
scanf("\n%d", &PropertyID);
printf("\n%d", PropertyID);

TotalTaxDue = 0;


while (PropertyID != 0){


printf("\nEnter Property Value: ");
fflush(stdin);
scanf("\n%lf", PropertyValue);
printf("\n%lf", PropertyValue);

TaxDue = calcTax(PropertyValue);

printf("\nThe Tax due on this property is %10.21f", TaxDue);
TotalTaxDue += TaxDue;

printf("\nEnter PropertyID: ");
fflush(stdin);
scanf("\n%d", &PropertyID);
printf("\n%d", PropertyID);
}

printf("\nThe Tax due on this property is %10.21f", TaxDue);

fflush(stdin);
getchar();
return 0;
}

double calcTax(value)

{

double value;
double Tax;


Tax = value * 0.03;

return(Tax);
}
/* END OF FILE */
Please use code tags!
...and the syntax for a function foward declaration is:
return_type function_name(argument_type argument_name);
So in your case,I guess double calcTax(double value);

Aceix.
Last edited on
ok, thank you that fixed that problem. Now, I am getting this

Unhandled exception at 0x0fc100d8 (msvcr100d.dll) in house value problem.exe: 0xC0000005: Access violation writing location 0x00000000.

whenever I run the code, what is this, i have no idea how to fix this.
You have this sequence:
1
2
3
4
printf("\nEnter PropertyID: ");
 fflush(stdin);
 scanf("\n%d", &PropertyID);
 printf("\n%d", PropertyID);

and this sequence:
1
2
3
4
printf("\nEnter Property Value: ");
 fflush(stdin);
 scanf("\n%lf", PropertyValue);
 printf("\n%lf", PropertyValue);

What is different and why?

By the way fflush(stdin); has undefined (or unspecified) behavior according to the language standard. It does something useful with some compilers. I would avoid using it, especially if you want to write portable code.
Topic archived. No new replies allowed.