That Constant Double to Float newbie thing
Hi, newbie here. I am reading my first C book and I am attempting to compile the code so I can write it as I practice. I googled this error and it told me to put an " f " after %.07 sales tax which gives me a whole new set of errors. If I copied the code straight out of the book why am I having problems? Also I was wondering if the tabbing is correct in this code so I know I am doing it right.
Thanks :)
Code:
/* Computes net tire sales */
#include <stdio.h>
main()
{
int numTires;
float tirePrice, beforeTax, netSale;
float taxRate = .07; /* Sales Tax */
/* Ask user for values */
printf("how many tires bought? ");
scanf(" %d", &numTires);
printf("How much is each tire? ");
scanf(" %f", &tirePrice);
/* Computer the Sale */
beforeTax = tirePrice * numTires;
netSale = beforeTax + (beforeTax * taxRate);
printf("Your total sale is %.2f\n", netSale);
return 0;
}