Home > Backend Development > C++ > body text

C program to calculate amount with tax using assignment operator

PHPz
Release: 2023-08-26 13:53:22
forward
650 people have browsed it

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;
}
Copy after login

Output

enter the money with dollar symbol:250$
amount after adding tax= 295.000000
Copy after login

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;
}
Copy after login

Output

enter the money with dollar symbol:250$
amount after adding tax= 300.000000
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!