-
VAT Calculation
Hi. Only being pragramming for a few weeks now, hence the questions.
For our latest assignment, we have been giving three codes to write, one of which is required to take price and VAT, and calculate the total cost. Here is the code so far:
Code:
/* VAT Calculation*/
/* By Luke Sowersby */
/* 05/03/08 */
#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
float vat, price;
printf("Please enter the VAT percentage:\n");
scanf("%f",&vat);
printf("Please enter the item value:\n");
scanf("%f",&price);
float price_to_cost_conversion(price, vat)
{
float cost;
cost=((1+(vat/100))*price);
return cost;
}
printf("The total price is %f",price_to_cost_conversion);
}
I was just hoping someone could point me in the right direction please, as to were i am going wrong.
Thanks,
Luke.
-
Also, note that the following code:
Code:
printf("The total price is %f",price_to_cost_conversion);
Is producing the following output:
"The total price is 0.0000" so i'm thinking the error lies within the function?
-
you have a body of the function instead of the call to this funtion
take body of it - out of main, and call it before printing the result
-
And another tip: indent your code (use tabs), like:
Code:
if(a == b)
{
printf("a is equal to b");
}
main() returns an int:
Code:
int main()
{
// your code
return 0;
}
You don't need conio.h in this piece of code, so why include it? Also note that conio.h isn't standard.
-
Finally got the program working with some additional features. Thanks for the help.
I usually do indents after i've finished experimenting with the code, and the libaries/titles at the top are what i c+p for each code i've been doing so far.