![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C program on calculating the amount with tax using assignment operator
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
",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
",value); return 0; }
Output
enter the money with dollar symbol:250$ amount after adding tax= 300.000000
Advertisements