Write a program that asks the user to enter the price of an item. It will then compute the 6.5% sales tax amount, and display the original price, the sales tax amount, and the total amount due on three separate lines with appropriate labels.
Write a program that asks the user to enter the price of an item. It will then compute the 6.5% sales tax amount, and display the original price, the sales tax amount, and the total amount due on three separate lines with appropriate labels.
tick tick tick ....
The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss
Code:#include <stdio.h> main() { int value1; float num; num = 6.5; printf("Please enter sales price: "); scanf ("%i", &value1); printf ("\n\nYour Sales price is: %i\n", value1); printf ("The Sales Tax is: %.1f%\n", num); printf ("Your Total is: "); getchar(); }
An integer is "%d" in the printf statement. A "%" is printed by using "%%"
Define main as "int main()" and make sure that it returns a 0 "return 0;"
Use the "+" and "*" to work out your answers.
Fact - Beethoven wrote his first symphony in C
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Unless this is the "call a friend" stage on who wants to be a millionaire I am not interested.
1. Get rid of gets(). Never ever ever use it again. Replace it with fgets() and use that instead.
2. Get rid of void main and replace it with int main(void) and return 0 at the end of the function.
3. Get rid of conio.h and other antiquated DOS crap headers.
4. Don't cast the return value of malloc, even if you always always always make sure that stdlib.h is included.