Home  >  Article  >  Backend Development  >  C program to calculate amount with tax using assignment operator

C program to calculate amount with tax using assignment operator

PHPz
PHPzforward
2023-08-26 13:53:22608browse

C program to calculate amount with tax using assignment operator

Question

Write a C program that enters a dollar amount and then adds 18% tax to display the amount.

Solution

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.

Example

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;
}

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 -

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;
}

Output

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete