Problem
Write a C Program to enter the amount in dollars and then display the amount by adding 18% as tax.
Solution
Let’s consider the restaurant person adding 18% tax to every bill of the customer.
The logic applied to calculate tax is −
value=(money + (money * 0.18));
The money should be multiplied by 18% and add to the money, then the restaurant person can receive the amount from a customer with tax.
Example
#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\n",value);
return 0;
}Output
enter the money with dollar symbol:250$ amount after adding tax= 295.000000
Example
Let us consider the same program by changing the percentage −
#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\n",value);
return 0;
}Output
enter the money with dollar symbol:250$ amount after adding tax= 300.000000