Home > Article > Backend Development > C program to calculate amount with tax using assignment operator
Write a C program that enters a dollar amount and then adds 18% tax to display the amount.
Let's consider the restaurant personnel adding an 18% tax to each customer's bill.
The logic used to calculate the tax is -
value=(money (money * 0.18));
The money should be multiplied by 18 % and added to the money, the restaurant staff can then receive the tax-included amount from the customer.
Live Demonstration
#include<stdio.h> int main(){ float money,value; printf("enter the money with dollar symbol:"); scanf("%f",&money); value=(money + (money * 0.18)); printf("amount after adding tax= %f</p><p>",value); return 0; }
enter the money with dollar symbol:250$ amount after adding tax= 295.000000
Let us consider the same program by changing the percentage -
Live demonstration
#include<stdio.h> int main(){ float money,value; printf("enter the money with dollar symbol:"); scanf("%f",&money); value=(money + (money * 0.20)); printf("amount after adding tax= %f</p><p>",value); return 0; }
enter the money with dollar symbol:250$ amount after adding tax= 300.000000
The above is the detailed content of C program to calculate amount with tax using assignment operator. For more information, please follow other related articles on the PHP Chinese website!